I'm writing a little message board (yes, I know there are free ones)
Anyway, after making a new topic the message from making that topic obviously has to become the first post in it, so as soon as I create a topic I run a query to put the information into the posts table.
To do this I have to get the id of the topic I just posted, I'm using the below at the moment...
$newtopic=mysql_query("SELECT topic_id FROM mbtopics ORDER BY topic_id",$db);
while($nti=mysql_fetch_array($newtopic)) {
$new_topic_id = $nti["topic_id"];
}
and relying upon the fact that it just grabs the latest topic_id for me, I'd be much happier using something like
$newtopic=mysql_query("SELECT MAX(topic_id)FROM mbtopics",$db);
but that doesn't work for some reason, can someone tell me what I've missed, I got the MAX() part out of the mysql manual.
Thanks a lot for any help