I have a simple database with 2 tables. Table 1 = Product Info, and Table 2 = Product Stats. I could have it all in one table, but I use two tables to keep things organized. I have a unique ID that ties the two tables together.
Now, I have a little problem adding a new product to my database (with a php script). This is what I have:
The problem is that sometimes when I add a new product, the ID will be different in each table. For example, I just added a new product, and the ID in table "products" was 114 while the ID in table "stats" was 115. This of course causes problems, each product has to have the same ID on both tables.
mysql_query("INSERT INTO products
(name,description,price,size,weight) VALUES(''$name','$desc','$price','$size','$weight') ")
mysql_query("INSERT INTO stats
(popularity,sales,opinions) VALUES('','','') ")
Is there a better query I could use? The products table always has info inserted, but the stats tables starts-off with all values being empty (they get populated with time, as sales start, etc)