kiksy Posted July 7, 2010 Share Posted July 7, 2010 Hi there, Im guessing im missing something obvious and making this hard for myself.... Running : 5.0.81-community $result = 'Select ID FROM comments HAVING MAX(id) > 1'; $row = mysql_query($result); echo $row['0']; Table structure is ID as primary, then USERNAME , COMMENT, DATE, VALIDATED All im trying to do is select the highest ID and then echo it , Ive searched around and found a few solutions but none seemed to work. All I want is the ID number as a $ . Any help at all appreciated. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/207036-noob-question-displaying-highest-id-in-a-table/ Share on other sites More sharing options...
ejaboneta Posted July 7, 2010 Share Posted July 7, 2010 <?php $sql= 'Select MAX(id) FROM table'; $query = mysql_query($sql); $fetch = mysql_fetch_row($query ); echo $fetch['0']; ?> Link to comment https://forums.phpfreaks.com/topic/207036-noob-question-displaying-highest-id-in-a-table/#findComment-1082613 Share on other sites More sharing options...
kiksy Posted July 7, 2010 Author Share Posted July 7, 2010 ahhhh! Thanks so much! Kicking myself now! Thanks again, hope I can help you some other day. Link to comment https://forums.phpfreaks.com/topic/207036-noob-question-displaying-highest-id-in-a-table/#findComment-1082623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.