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? Quote Link to comment 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 Quote Link to comment 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"; Quote Link to comment 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! Quote Link to comment 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? Quote Link to comment 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"; Quote Link to comment Share on other sites More sharing options...
frijole Posted March 5, 2008 Share Posted March 5, 2008 nice, thanks bpops. Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.