hi
I use this
$query = "SELECT * FROM info ORDER BY id DESC limit 10";
$result = @mysql_query( $query );
$row = mysql_fetch_array($result);
print_r($row);
but it gets just the last row
hi
I use this
$query = "SELECT * FROM info ORDER BY id DESC limit 10";
$result = @mysql_query( $query );
$row = mysql_fetch_array($result);
print_r($row);
but it gets just the last row
The query is correct. If you seem to be only getting one row, it's a factor external to the query causing it: either you only have one row in the table, or your application logic is hosed so that it looks like you only have one row.
Edit: Yeah, now that you've posted your code, we can see that it's that your application logic is hosed. Try this:
$result = mysql_query($query);
$rows = array();
while($row = mysql_fetch_array($result))
$rows[] = $row;
mysql_fetch_array
does not fetch an array of rows.
It fetches an array of columns from a single row.
To get all rows, you have to run it in a loop:
$query = "SELECT * FROM info ORDER BY id DESC limit 10";
$result = @mysql_query( $query );
while ($row = mysql_fetch_array($result))
print_r($row);