How to set ID of item when the item is not yet created..?

Posted by hoppl on Stack Overflow See other posts from Stack Overflow or by hoppl
Published on 2010-05-28T19:10:43Z Indexed on 2010/05/28 19:11 UTC
Read the original article Hit count: 113

Filed under:
|
|

I'll try to make myself clear with an example:

Imagine an admin page to add a product to a database (product list). When I open the ADD ITEM page, the item is not yet created (not until I click the submit button), but let's say I want to add categories this product will appear in (with AJAX for example). When I run the AJAX script, i need to tell it which ID (my product) to put these categories in...

How should I do this.?

Is inserting a blank item in the database (to get mysql_insert_id) when the page opens a good way to do this.? Is it prone to conflicts or errors..?

How do you guys do it.?

© Stack Overflow or respective owner

Related posts about php

Related posts about best-practices