I am trying to get information from my database that contains a foreign key that relate to another table,
I am trying to enter details of an order and then have the customer ID of that order enter automatically from the customer table.
[B]Customer Table
[/B]
CREATE TABLE IF NOT EXISTS `customer` (
`CustomerID` int(11) NOT NULL DEFAULT '0',
`Customer Name` varchar(50) NOT NULL,
`Customer Address` varchar(60) NOT NULL,
`Customer Address1` varchar(60) NOT NULL,
`Customer Address2` varchar(60) NOT NULL,
`County` varchar(15) NOT NULL,
`Customer Postcode` int(6) DEFAULT NULL,
`Customer Tel No` int(11) NOT NULL,
`Customer Email` varchar(50) DEFAULT NULL,
PRIMARY KEY (`CustomerID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
[B]Order Table
[/B]
CREATE TABLE IF NOT EXISTS `order` (
`OrderID` int(10) NOT NULL,
`OrderDateTime` datetime DEFAULT NULL,
`CustomerID` int(11) DEFAULT NULL,
`Delivery_Date` datetime DEFAULT NULL,
`Actual_Delivery` datetime DEFAULT NULL,
PRIMARY KEY (`OrderID`),
KEY `Order_FK1_customer` (`CustomerID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
I have come up with the following code but it says that there is a error with it
<?php
include ("db.php");
include ("functions.php");
$ODateTime=$_POST["datetime"];
$Cid=getCustomerID($_POST["cid"]);
$ODeliveryDate=$_POST["deliverydate"];
$OActualDelivery=$_POST["actualdelivery"];
$str1="insert into order(OrderDateTime,CustomerID, ,DeliveryDate, ActualDelivery) values('$ODateTime','$Cid','$ODeliveryDate','$ActualDelivery')";
mysql_query($str1);
print ($str1);
?>