davez Posted August 19, 2011 Share Posted August 19, 2011 Hello world! It been a week now, I try to make a code to display the total number of users on my home page. I almost succeeded, but I am stuck on a problem. The code displays all the 'ID' on the page, and I want only the last 'ID' Here is the code: <? session_start(); include "config.php"; global $c,$loggedin; include "data.php"; global $config; include "funciones.php"; ?> <? $tabla = mysql_query("SELECT id FROM tb_users"); while ($registro = mysql_fetch_array($tabla)) echo " ". $registro["id"] ."" ?> Thank You! davez Link to comment https://forums.phpfreaks.com/topic/245157-stuck-on-a-problem/ Share on other sites More sharing options...
MasterACE14 Posted August 19, 2011 Share Posted August 19, 2011 $tabla = mysql_query("SELECT id FROM tb_users LIMIT 1"); ? Link to comment https://forums.phpfreaks.com/topic/245157-stuck-on-a-problem/#findComment-1259205 Share on other sites More sharing options...
davez Posted August 19, 2011 Author Share Posted August 19, 2011 Almost! Now I have the first 'ID' of my list, but I need the last 'ID' Thank You very much! :-) Link to comment https://forums.phpfreaks.com/topic/245157-stuck-on-a-problem/#findComment-1259209 Share on other sites More sharing options...
MasterACE14 Posted August 19, 2011 Share Posted August 19, 2011 this should do the trick... $tabla = mysql_query("SELECT id FROM tb_users ORDER BY id DESC LIMIT 1"); // orders the results by the 'id' field in descending order Link to comment https://forums.phpfreaks.com/topic/245157-stuck-on-a-problem/#findComment-1259210 Share on other sites More sharing options...
davez Posted August 19, 2011 Author Share Posted August 19, 2011 wow..loll Thank You very much, this is very appreciate !!! My problem is solved ! ThX! :-D Link to comment https://forums.phpfreaks.com/topic/245157-stuck-on-a-problem/#findComment-1259234 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.