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
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'";

 

Link to comment
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'";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.