Page 1 of 1

Get Id Number

Posted: Tue Aug 30, 2005 7:39 pm
by blacksnday
If I do something like

Code: Select all

$sql = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 5");
How do I get the ID number for each of the 5 items to print on page?

Posted: Tue Aug 30, 2005 7:58 pm
by Deemo

Code: Select all

while ($row = mysql_fetch_array($sql))
{
  //Do what you want here. Each column name is the associative index to $row which is an array
  echo $row['id'];
}
That simply outputs the 5 id numbers