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? 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. 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. 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
Archived
This topic is now archived and is closed to further replies.