Jump to content

Two table insert using relationship


phpjay

Recommended Posts

i have two tables 1 is remarks one is tbltracking i have remarks_id as primary key in remarks table and ID as primary key also in tbltracking

 

i need to insert a data in remarks table using selecting the table ID from tbltracking table..

 

structure of my two tables:

remarks:

 

remarks_id: primary key

remarks: varchar(255)

date: time stamp

 

 

tbltracking:

ID: primary key

name:varchar(255)

DateReceived:date

Link to comment
https://forums.phpfreaks.com/topic/241715-two-table-insert-using-relationship/
Share on other sites

i have a code here i want to update and insert a data.. how i can add insert here in my code where table2.ID= to remarks.ID

 

	 include ('connection.php');

	$con = mysql_connect("$host","$username","$password");
			if (!$con)
			  {
			  die('Could not connect: ' . mysql_error());
			  }

			mysql_select_db("$db", $con);



			$acft = $_POST['acft'];
			$DateIssued = $_POST['DateIssued'];
			$IssuedTo = $_POST['IssuedTo'];
			$ID = $_POST['ID'];
			$remarks = $_POST['remarks'];
			$sql="UPDATE $table2 SET acft='$acft', DateIssued='$DateIssued', IssuedTo='$IssuedTo'  where ID='$ID'";

 

i have a code here i want to update and insert a data.. how i can add insert here in my code where table2.ID= to remarks.ID

 

	 include ('connection.php');

	$con = mysql_connect("$host","$username","$password");
			if (!$con)
			  {
			  die('Could not connect: ' . mysql_error());
			  }

			mysql_select_db("$db", $con);



			$acft = $_POST['acft'];
			$DateIssued = $_POST['DateIssued'];
			$IssuedTo = $_POST['IssuedTo'];
			$ID = $_POST['ID'];
			$remarks = $_POST['remarks'];
			$sql="UPDATE $table2 SET acft='$acft', DateIssued='$DateIssued', IssuedTo='$IssuedTo'  where ID='$ID'";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.