Page 1 of 1

Adding up all tables in a database

Posted: Sun Dec 15, 2002 6:58 pm
by kkurkowski
Ok, on the side of my website I have a navi bar. When I click Home it goes to news.php. I want home to appear like this Home (# of post).
Is there any way to just put the number of the last post id in???

Posted: Sun Dec 15, 2002 7:03 pm
by nathus
assuming that your id's are auto incremented, you could run a query like

Code: Select all

$query = "SELECT MAX(id) FROM news_news";
$result = mysql_query($query);
$result  = mysql_fetch_row($result);
$newest_id = $result[0];
this will get the id of the most recently entered item in the database.