adzie Posted April 17, 2008 Share Posted April 17, 2008 is it possible when entering a new member in the database via a form, that the member number can automatically display the next available row number in the DB? Link to comment https://forums.phpfreaks.com/topic/101524-generate-member-number-based-on-next-row-number-in-db/ Share on other sites More sharing options...
zenag Posted April 17, 2008 Share Posted April 17, 2008 after insert command echo mysql_insert_id()+1; Link to comment https://forums.phpfreaks.com/topic/101524-generate-member-number-based-on-next-row-number-in-db/#findComment-519306 Share on other sites More sharing options...
adzie Posted April 17, 2008 Author Share Posted April 17, 2008 excellent, the DB has got into a real mess previously as the memebr number was dictated by the person entering the new members details of a spreadsheet. Hopefully this will help to keep things 'tidy' Link to comment https://forums.phpfreaks.com/topic/101524-generate-member-number-based-on-next-row-number-in-db/#findComment-519323 Share on other sites More sharing options...
PFMaBiSmAd Posted April 17, 2008 Share Posted April 17, 2008 Because of the possibility of concurrent access, you CANNOT use mysql_insert_id()+1 for any purpose other than to display the number. As soon as you attempt to actually use that number, you will eventually create a mess with multiple records having the same number in it. You need to use an auto-increment field to insure uniqueness. Link to comment https://forums.phpfreaks.com/topic/101524-generate-member-number-based-on-next-row-number-in-db/#findComment-519451 Share on other sites More sharing options...
adzie Posted April 17, 2008 Author Share Posted April 17, 2008 the field ID which is the table key is also autoincrement Link to comment https://forums.phpfreaks.com/topic/101524-generate-member-number-based-on-next-row-number-in-db/#findComment-519882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.