I need to get the last username registered in my members table. The last registered has the highest ID number.
At the moment, I can get the highest ID with this code, but I need to get the lowest.
$resultlatestuser = mysql_query("SELECT * from $tbl_name ORDER BY 'id' DESC LIMIT 0,1;"); $row = mysql_fetch_row($resultlatestuser); echo $row[1];
This echos the ID as john, but john has the lowest ID: 1.
This is what my database looks like, for example I need Dayancbro echo'd because he has the highest ID.
是时候使用聚合函数了:
SELECT MAX(id) FROM $tablename
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.