'Get the latest data [duplicate]

I need help in my project i want to get the latest messages record for each user who has sanded messages to each other

For example

| Index_No | Message_From  | Message_To     | Message        |
| -------- | ------------- | -------------- | -------------- |
| 1        | [email protected] | [email protected] | Hello ade9     |
| 2        | [email protected] | [email protected] | Hello ade9     |
| 3        | [email protected]| [email protected]  | yes ken        |
| 4        | [email protected]| [email protected]  | yes ade        |

i have the above table in which if i want to search the messages of [email protected] it showed show me the the latest message with each users like the expected result should be

| Index_No | Message_From  | Message_To     | Message        |
| -------- | ------------- | -------------- | -------------- |
| 3        | [email protected]| [email protected]  | yes ken        |
| 4        | [email protected]| [email protected]  | yes ade        |

So how i will perform the MYSQL Query for this in PHP

PLEASE HELP ME IN THIS PROBLEM DONT REFER ME TO ANOTHER QUESTION I AM NEW IN PHP



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source