Danny620 Posted November 3, 2009 Share Posted November 3, 2009 <?php require('settings/control.php'); require('lib/lib.php'); // Query the database: $q = "SELECT MAX(id) FROM users"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); $max_id = mysqli_fetch_array($r); echo $max_id[id]; ?> it should echo 13 as thats the highest id but it does'tn Quote Link to comment https://forums.phpfreaks.com/topic/180191-capturing/ Share on other sites More sharing options...
mikesta707 Posted November 3, 2009 Share Posted November 3, 2009 try $q = "SELECT MAX(id) as maxID FROM users" $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); $max_id = mysqli_fetch_array($r); echo $max_id['maxID']; it would help if you also said what that code echoed Quote Link to comment https://forums.phpfreaks.com/topic/180191-capturing/#findComment-950536 Share on other sites More sharing options...
Garethp Posted November 3, 2009 Share Posted November 3, 2009 Well, I'd use $q = "SELECT * FROM `users` ORDER BY `id` DESC LIMIT `"; $r = mysql_query($q); $r = mysql_fetch_array($r); echo $r['id']; Quote Link to comment https://forums.phpfreaks.com/topic/180191-capturing/#findComment-950537 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.