Hye all!! I got some basic question about SQL + PHP. I would like to know with PHP to call last row of ID? I mean like image above, i would like to view only that 1009 as output on my website and NOT all of from 1,1007,1005,1006,1008 & 1009. I alread try with
Code:
$id = $row['id'];
echo "Last ID is - ".$id."";
But that will list all of that ID in the row, so can someone tell me what a exactly "$" i have to use.
If u dont mind i also need to know any referrer URL for SQL newbies where i can know & understand any basic SQL library key/etc.
Assuming that the user_id is of type "Auto Increment", you can be assured that they are in numerical sequence. So, this would work:
Code:
SELECT user_id FROM site_users ORDER BY user_id DESC LIMIT 1;
It is also possible that the following will work:
Code:
SELECT max(user_id) AS user_id FROM site_users;
But, I am not where I can test that last one. (I cannot remember if it needed a GROUP BY clause on it.
Regarding learning SQL, I believe that I already gave you a good book? Other than that, I really just like mySQL's on-line command reference.
Hye again montego, yes u right that book is really a good one:p i really appreciate it. I just buy that book a couple weeks ago but still not complete to read n try all of exercise there:p But i will/must read n do any exercise to make sure i can become a good programmer. Whatever, thanxs for your code so now i already get that "keyword" i really appreciate it. Dont know how i can express my big appreciate on you since u introduce to me that book. But sometimes, although i already got a good book maybe i still got something to ask here wish all of my friends can help me here Once i already be a good programmer of course i will help them like u help me. Thanxs dude:p
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum