I have one table, we'll call it primary. I want to update my other table(s) based on the primary table.
_primary:
id | product | stylenum | name | price
Other table(s)
id | product | user | checked
// This table will be used somewhat as a checklist, where users can login and see if they have said product.
I want to add rows to other table(s) based on 'product' from the _primary table. I'm not sure to how to go about doing this, would I go ahead and use the INSERT statement? Or would the following code be sufficent?
$result=mysql_query("SELECT product FROM dbname._primary WHERE id=$id");
$row=mysql_fetch_array($result);
$product = $row["product"];
INSERT INTO dbname.table (id,product,user,checked) VALUES ($id,$product,$user,$checked);
I want the tables to update automatically. Like if I added a new product to _primary, I want this product to show up in subsequent tables too.
Thank you for your time. Have a nice evening.