I'm trying to figure out how to make a script that will connect to my mySQL database and select the three highest ID number from the database. I am creating a news script for my site, it will connect to my forums database and give me the last three post in my forum. I created its own forum and its ID is 12. I've been able to connect to the datbase and retrieve the data, but since the forum is updated regularly, I need it to check in forum 12 the latest post.
Heres what I got so far:
<?
$db = mysql_connect("localhost", "user", "pass");
mysql_select_db("database", $db);
$result = mysql_query("SELECT * FROM ib_topics WHERE forum_id=12",$db);
$myrow = mysql_fetch_array($result);
?>
<? echo $myrow ["title"]?>
Now:
<? echo $myrow ["title"]?>
Will echo the data from the title field. But if I update the forum, there will be more than one title with the same forum ID. So I need it to check the ID of each field, and select the three highest. I've looked at php.net but I didnt see anything for selecting the highest number from the database.
Can someone help me out here? How can I get php to check for the highest ID number in a mySQL database.