uramagget Posted March 5, 2008 Share Posted March 5, 2008 Hi, can anybody assist me on a mySQL based issue I have? I have a comics system that I wrote just now, and well, the only thing I need to complete it is to display the newest comic first. For example, the way I usually look for comments is by passing a mySQL query that locates the comic using $_GET. Though, I have seen many people first land without the $_GET being set. So, is there a mySQL query out there that selects the newest comic? I imagine it would select the comic with the highest ID, no? Link to comment https://forums.phpfreaks.com/topic/94582-displaying-newest-row/ Share on other sites More sharing options...
graham23s Posted March 5, 2008 Share Posted March 5, 2008 You could do: $query = "SELECT * FROM `table` ORDER BY `comic_id` DESC"; Graham Link to comment https://forums.phpfreaks.com/topic/94582-displaying-newest-row/#findComment-484309 Share on other sites More sharing options...
wildteen88 Posted March 5, 2008 Share Posted March 5, 2008 Use mysql_insert_id or Gramham's query. However if you use the query then limit the returned results to only one: $query = "SELECT * FROM `table` ORDER BY `comic_id` DESC LIMIT 1"; Link to comment https://forums.phpfreaks.com/topic/94582-displaying-newest-row/#findComment-484321 Share on other sites More sharing options...
uramagget Posted March 5, 2008 Author Share Posted March 5, 2008 Ah, silly me. Thanks graham and wildteen! Link to comment https://forums.phpfreaks.com/topic/94582-displaying-newest-row/#findComment-484325 Share on other sites More sharing options...
frijole Posted March 5, 2008 Share Posted March 5, 2008 how would you get the newest three by date? Link to comment https://forums.phpfreaks.com/topic/94582-displaying-newest-row/#findComment-484361 Share on other sites More sharing options...
bpops Posted March 5, 2008 Share Posted March 5, 2008 how would you get the newest three by date? Same way as above, with slight modification $query = "SELECT * FROM `table` ORDER BY `date` DESC LIMIT 3"; Link to comment https://forums.phpfreaks.com/topic/94582-displaying-newest-row/#findComment-484364 Share on other sites More sharing options...
frijole Posted March 5, 2008 Share Posted March 5, 2008 nice, thanks bpops. Link to comment https://forums.phpfreaks.com/topic/94582-displaying-newest-row/#findComment-484388 Share on other sites More sharing options...
uramagget Posted March 7, 2008 Author Share Posted March 7, 2008 Well, I have run into a problem, but not with with the provided code. It works great, though the problem is, my comic has a built-in comics system. I would like to, for example, grab the comments that apply to the newest comic. How would I go to doing this? Link to comment https://forums.phpfreaks.com/topic/94582-displaying-newest-row/#findComment-486223 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.