How to make the data display non-repeated, only display the latest data query database with PHP, but repeated data display, how to make the data not repeated:
The status of the user ID 0193 06:25:35 is displayed, but it is also displayed at 11:25:35. how can I display only the latest data of the same version number,
The webpage code is as follows:
Data Query
If ($ _ REQUEST ['submit ']! = "")
{
$ Link = mysql_connect ("127.0.0.1", "root", "12345678 ");
If (! $ Link) echo "no connection successful! ";
Else echo "connection successful! ";
Mysql_select_db ("busap", $ link); // select a database
// Control query conditions
$ Q = "SELECT * FROM research where banben like '% {$ _ REQUEST ['banben']} %' AND linename like '% {$ _ REQUEST ['xianlu']} % 'AND zhuangtai like' % {_ _ REQUEST ['zhuangtai']} % 'order by busname asc ";
// Mysql_query ("set names GB2312"); // prevents garbled characters
$ Rs = mysql_query ($ q); // Obtain a dataset
$ Assoc = mysql_num_rows ($ rs); // The number of affected rows. mysql_fetch_assoc was used.
Echo "$ assoc ";
$ Row = mysql_fetch_array ($ rs); // you only need to add this row back.
If (! $ Rs) {die ("Valid result! ");}
}
?>
Line |
Center No. |
Line |
Vehicle ID |
Transmission mode |
Media version |
Date |
Time |
Status |
If ($ _ REQUEST ['submit ']! = ""){Do {?> If ($ row [4] = "0 "){$ Leixing = "auto ";}Else{$ Leixing = "manual ";} If ($ row [8] = "fin "){$ Zhuangtai = "finished ";}Else{$ Zhuangtai = "unfinished ";}?>
|
|
|
|
|
|
|
|
|
Reply to discussion (solution)
Add an ID column to update the displayed data to 0. when querying, only the data marked as 0 is queried.
Just write a judgment. the version number is the same and the maximum time record is used.
Can you give me a detailed judgment code? I am a beginner, I am a little white.
Try
$ Q = "SELECT *, max (media version) FROM research where banben like '% {$ _ REQUEST ['banben']} %' AND linename like '% {$ _ REQUEST ['xianlu']} %' AND zhuangtai like' % {$ _ REQUEST ['zhuangtai']} % 'group by media version order by max (media version) busname asc ";
Is to take the maximum value of the media version, and then display
Isn't that easy?
You can use the max function.