Reputation: 133
I'm trying to limit the array mysql_fetch_assoc($query)
, and am unsure on how I would go about it.
$query = mysql_query('SELECT * FROM table ORDER BY id DESC');
while($output = mysql_fetch_assoc($query))
{
//do something
}
Do you add a counter or something? How do you add this counter?
I'm really confused about mysql_query
and mysql_fetch_assoc
. Please Help!
Upvotes: 0
Views: 122
Reputation: 167250
LIMIT
SELECT * FROM table ORDER BY `id` DESC LIMIT 10;
Haven't you seen phpMyAdmin always limiting to 30
?
Upvotes: 1
Reputation: 324830
After your ORDER BY id DESC
, add LIMIT 100
(or whatever number you want). For the next 100 rows, use LIMIT 100,100
, then LIMIT 200,100
and so on.
Upvotes: 2
Reputation: 204924
You can limit the results directly in the SQL query. To get the top 100 records do
SELECT * FROM table
ORDER BY id DESC
LIMIT 100
Upvotes: 1