How to display the latest data without repeating the data display

Source: Internet
Author: User
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! ");}
}
?>
















































If ($ _ REQUEST ['submit ']! = ""){Do {?> If ($ row [4] = "0 "){$ Leixing = "auto ";}Else{$ Leixing = "manual ";} If ($ row [8] = "fin "){$ Zhuangtai = "finished ";}Else{$ Zhuangtai = "unfinished ";}?>

Line

Center No.

Line

Vehicle ID

Transmission mode

Media version

Date

Time

Status



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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.