Adding up all tables in a database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kkurkowski
Forum Commoner
Posts: 53
Joined: Mon Dec 09, 2002 4:44 pm
Location: Michigan

Adding up all tables in a database

Post 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???
User avatar
nathus
Forum Commoner
Posts: 49
Joined: Thu Dec 12, 2002 6:23 pm

Post 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.
Post Reply