mysql_query LIMIT won't work

Status
Not open for further replies.

bodge

ayy lmao
Oct 31, 2011
406
54
Hi Devbest, the LIMIT in my mysql_query won't work

PHP:
    $userstatus = mysql_query("SELECT * FROM `users_status` WHERE `user_id` ='".$id."' ORDER BY `status_id` LIMIT 10");

It just shows the newest column data and doesn't show any other previous data, even though LIMIT 10 should display the first 10 results from the database.


Code:
while ($row = mysql_fetch_array($userstatus, MYSQL_ASSOC)){
   
        $status = $row['status_message'];
   
    }


echo $status

database table:

2MLOupPg7DCoeeQC11HS62


Thanks inadvanced :)
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,637
2,389
Are you sure this doesn't work?

PHP:
$userstatus = mysql_query("SELECT * FROM `users_status` WHERE `user_id` ='".$id."' ORDER BY `status_id` DESC LIMIT 10");
 

bodge

ayy lmao
Oct 31, 2011
406
54
Are you sure this doesn't work?

PHP:
$userstatus = mysql_query("SELECT * FROM `users_status` WHERE `user_id` ='".$id."' ORDER BY `status_id` DESC LIMIT 10");

Fixed, I added
Code:
    while ($row = mysql_fetch_array($userstatus, MYSQL_ASSOC)){
        echo "<br>";
        echo $row['status_message'] . "";
        echo "<br>";
   
    }

Underneath the $userstatus
 
Status
Not open for further replies.

Users who are viewing this thread

Top