Forum Moderators: open
I'm sending a query to my database to get some information to build an array:
$result=mysql_query("SELECT * FROM table_name");
$row=mysql_fetch_array($result);
$list=array();
while($row=mysql_fetch_array($result)) array_push($list,array($row['x'],$row['y'],$row['z']));
Later in my page I'll output a list like this:
for($i=1;$i<20;$i++) echo "$hot[$i-1][0], $hot[$i-1][1], $hot[$i-1][2]";
The thing is, I only need the top 20 rows form my table, but I'm having the script read everything in the database and putting that information in the array.
I think this is my weak spot:
$result=mysql_query("SELECT * FROM table_name");
How can I change that to limit it to just the top 20 records?
Thanks so much