Styles2304 Posted August 15, 2007 Share Posted August 15, 2007 Each post in my announcement section has an IndexNo . . . so far I've had to do enter that automatically. How do I rig something up so that php will extract the most recent (or last entered) news post's IndexNo and increase it? The IndexNo is stored as an integer so increasing it is no worry . . . my real problem is how do I tell mySQL to give me the most recently posted news article? Quote Link to comment https://forums.phpfreaks.com/topic/65135-solved-increasing-certain-values-in-mysql-database/ Share on other sites More sharing options...
lemmin Posted August 15, 2007 Share Posted August 15, 2007 The most recently posted one is the one with the highest IndexNo, right? If so, "UPDATE table SET IndexNo=IndexNo+1 WHERE IndexNo=(SELECT IndexNo From table ORDER BY IndexNo DESC LIMIT 1)" That should do it. Quote Link to comment https://forums.phpfreaks.com/topic/65135-solved-increasing-certain-values-in-mysql-database/#findComment-325101 Share on other sites More sharing options...
Barand Posted August 15, 2007 Share Posted August 15, 2007 Just define as "auto_increment" than it's done for you. Quote Link to comment https://forums.phpfreaks.com/topic/65135-solved-increasing-certain-values-in-mysql-database/#findComment-325102 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.