select and insert from form to database
Posted: Wed Mar 15, 2006 2:11 pm
Here is the problem:
1-I've a table in my database named: mt_entry
2-This table has these fields: entry_id, entry_category,entry_text,title,date and so on...
3-I know to sending information via a form to this database, I can use a insert query.
But each time a user visits the form page to send a new entry to database, I need that a php code gets the last entry's id and adds 1 to it and put this id inot a hidden input inside the form,named "entry_id".
My question is that: how should I write such a code segment? and how can I be sure that every time a user sends an entry to database it will get a unigue id (the last entry's id + 1)?
1-I've a table in my database named: mt_entry
2-This table has these fields: entry_id, entry_category,entry_text,title,date and so on...
3-I know to sending information via a form to this database, I can use a insert query.
But each time a user visits the form page to send a new entry to database, I need that a php code gets the last entry's id and adds 1 to it and put this id inot a hidden input inside the form,named "entry_id".
My question is that: how should I write such a code segment? and how can I be sure that every time a user sends an entry to database it will get a unigue id (the last entry's id + 1)?