Create table Cameras
(CameraID varchar (35),
CheckOutDate varchar(10),
ReturnDate varchar(10),
primary key(CameraID),
foreign key(CameraId) references History(CameraID));
Create table Borrowers
(PsuID int not null,
BorrowerName varchar(30),
Email varchar(50),
Telephone varchar(12),
ReasonUse varchar(200),
primary key(PsuID),
foreign key(PsuID) references History(PsuID));
Create table History
(PsuID int not null,
CameraID varchar (35),
BorrowedFrequency int,
primary key(PsuID, CameraID),
foreign key(PsuID) references Borrowers(PsuID),
foreign key(CameraID) references Cameras(CameraID));
This is my table
I want to insert Cameras and Borrowers at the same time
<?php
$CameraID = $_POST['cameraid'];
$CheckOutDate = $_POST['checkoutdate'];
$ReturnDate = $_POST['returndate'];
$PsuID = $_POST['psuid'];
$BorrowerName = $_POST['borrowername'];
$Email = $_POST['email'];
$Telephone = $_POST['telephone'];
$ReasonUse = $_POST['reasonuse'];
//Connect To Database
$hostname="localhost";
$username="your_dbusername";
$password="your_dbpassword";
$dbname="your_dbusername";
mysql_connect($hostname,$username, $password) or die ("ERROR: Unable to connect to database!");
mysql_select_db($dbname);
#Add new entry
$sql = "insert into Borrowers() values ()";
$result = mysql_query($sql, $conn) or die(mysql_error());
$sql = "insert into Cameras() values ()";
$result = mysql_query($sql, $conn) or die(mysql_error());
Hope I can get some helps,
Thanks