goatboy Posted January 17, 2007 Share Posted January 17, 2007 ok hope i don't make this too confusing.lets say i have a table called comments.A user can have multiple entries in the table or none, I want to be able to find the most recent post by a certain user.so lets say they posted comments last month, last week, and yesturday.what code would i use to retreive only the post from yesturday.the table contains the date they posted, the user id and what item they commented on.I need to be able to check when they posted last in comparison to the current date, i have that part of the code down just need to be able to find the last time they posted. Quote Link to comment https://forums.phpfreaks.com/topic/34621-find-the-last-entry-in-a-table-by-a-specified-user/ Share on other sites More sharing options...
dgiberson Posted January 17, 2007 Share Posted January 17, 2007 SELECT * FROM table WHERE userid = $userid ORDER BY date_time DESC LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/34621-find-the-last-entry-in-a-table-by-a-specified-user/#findComment-163099 Share on other sites More sharing options...
goatboy Posted January 17, 2007 Author Share Posted January 17, 2007 i feel so dumb, i should have known that.i think i'm brain dead after figuring out how to compare datesthanks Quote Link to comment https://forums.phpfreaks.com/topic/34621-find-the-last-entry-in-a-table-by-a-specified-user/#findComment-163101 Share on other sites More sharing options...
dgiberson Posted January 17, 2007 Share Posted January 17, 2007 no problem Quote Link to comment https://forums.phpfreaks.com/topic/34621-find-the-last-entry-in-a-table-by-a-specified-user/#findComment-163103 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.