Ask about general coding issues or problems here.
Moderators: macek, egami, gesf
I'm new to php and mysql and need some advices.
Is there a method to retrieve the primary key for the next database entry? I have defined some tables in mysql and would like to insert entries to the tables through php code,however, what is the best way to retrieve the next primary key( Max+1 ).
- New php-forum User
- Posts: 2
- Joined: Fri Apr 26, 2013 1:58 am
When you setup your table, set your primary key field to auto increment. Then when you insert, don't include that field in the fields to be inserted, and it will automatically be given the next available id
- php-forum Fan User
- Posts: 705
- Joined: Mon Oct 01, 2012 12:32 pm
Return to PHP coding => General
Who is online
Users browsing this forum: No registered users and 2 guests