Hello,
I'm trying to send some form data to two SQL tables. Below is the code I have. When I use the code below, it's showing that the information was successfully added. I go to the database and it adds the info to the restaurant table, but the "food" info is not added to the food type table.
Also, one final thing. 'Restaurant' is a foreign key in the food type table. How do I note that in the code below?
PHP Code:<?php require_once("db_connx.php");
$restaurant = $_POST['restaurant'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$type = $_POST['type'];
$cost = $_POST['cost'];
$food = $_POST['food'];
if (mysql_query ("INSERT INTO restaurant (Restaurant, Address, City, State, Zip, Phone, Type, AverageCost) VALUES ('$restaurant', '$address', '$city','$state', '$zip', '$phone', '$type', '$cost')INSERT INTO food type(Food Type) VALUES('$food')"))
{ echo "Restaurant successfully added to the database <br />";
}
else
{ echo "Error adding restaurant"; }
require_once("db_connx_close.php");
?>


Reply With Quote
Bookmarks