I Have 2 tables in my db that each have a column named Catergory.
Categories Table -
id | category_name
1 : basic
2 : midlevel
3 : highlevel
4 : profesional
Product Table -
id | product | category_name
1 : adsl 1G : basic
2 : adls 2G : midlevel
3 : adsl 3G : highlevel
4 : adsl 4G : profesional
When i update the *category_name* in the categories table i would like to change it in the Products table as well, but i am not sure on how to do this.
I couldnt find and answer because i dont know how to phrase it correctly.
Any help would be appreciated.
What my update.php looks like now:
db_update("UPDATE category SET
`category_name` = '".$_POST['category_name']."'
WHERE category_id = '".$id."'");
what is should look like:???
{code here}
Note: “FIXED – I forgot to send my old value to the save.php file so the $id never knew what to update”.
You could just run two queries changing both names:
If you want to do it in one string you can do this with multiple queries, a joined query or a stored procedure.
Multiple queries in one string:
Joined query:
If none of the above work I suggest changing your tables so there isn’t a matching name but a matching ID.
You’ll get the following: