Tuesday 15 May 2012

php - how do I select top 5 from a MySQL database -


Right now I am using this very complex method which I think can be very easy < Pre> & lt ;? Php $ a = 0; For ($ i = 100; $ i> = 0; $ i -) {$ query = mysql_query ("Choose data from data from where = $ i"); If ($ query) {$ data = mysql_fetch_array ($ query); A ++ $; If ($ a & lt; = 5) {? & Gt; & Lt; Img id = a & lt ;? Php ek $ a; ? & Gt; Src = "img.php? Id = & lt ;? Php $ data ['id'];? & Gt;" /> & Lt ;? Php}}}? & Gt;

The way I am connected to the data base, what I would like to know, is to know the ID of images with the top images, it will only work with 100 likes and if 2 is the same The amount will not work too, is there a better way of doing this? Firstly, you can write your SQL so that it sets and limits the set result.

Next, you can select more syntax in MySQL:

Mysql_functions should not be used. They have been disliked for a long time, consider switching to Mysqli_, or use better.

No comments:

Post a Comment