I am having trouble with the following issue: I have two tables:
category table:
category_id | category_name
brand table
brand_id | brand_name | category_id (FOREIGN KEY)
I was trying to insert a new brand name value using PHP with FOREIGN KEY that referenced to category id.
$insert = "INSERT INTO brand (category_id, brand_name) VALUES('$category_name','$brand')";
However it could not be added into the brand table.
category_idinto thebrandtable. When you want to retrieve data from thebrandtable, you can get the category name by using a query such asSELECT brand_name, category_name FROM brand b JOIN category c ON c.category_id=b.category_id