uwannadonkey Posted August 15, 2007 Share Posted August 15, 2007 there is prolly a simple answer to this: in my game, on the bottom, i wanna do a area where it says: total battles fought i have a table, which stores battle logs with a id, winner, and loser columns how do i grab the row with the biggest ID number(this way, i can use that as battles fought) Quote Link to comment https://forums.phpfreaks.com/topic/65083-solved-newbie-question/ Share on other sites More sharing options...
The Little Guy Posted August 15, 2007 Share Posted August 15, 2007 Something like this may work: <?php $sql = mysql_query("SELECT MAX(id) as maxID FROM tbale_name GROUP by id LIMIT 1")or die(mysql_error()); $row = mysql_fetch_array($sql); echo $row['maxID']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/65083-solved-newbie-question/#findComment-324818 Share on other sites More sharing options...
uwannadonkey Posted August 15, 2007 Author Share Posted August 15, 2007 now it just says "1" Quote Link to comment https://forums.phpfreaks.com/topic/65083-solved-newbie-question/#findComment-324821 Share on other sites More sharing options...
uwannadonkey Posted August 15, 2007 Author Share Posted August 15, 2007 fooled with it, and this works: $sql = mysql_query("SELECT MAX(ID) as maxID FROM battles")or die(mysql_error()); $row = mysql_fetch_array($sql); echo $row['maxID']; Quote Link to comment https://forums.phpfreaks.com/topic/65083-solved-newbie-question/#findComment-324829 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.