Click here to Skip to main content
15,867,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have inserted data into 4 tables in a database , and have total 4 primary keys one from each table , now i want to use these 4 keys as foreign keys in the 5th table , how can i insert data into fields of 5th table by using foriegn keys , which queery is being used at this place ...?
Posted
Comments
Rage 11-Mar-14 11:01am    
How did you insert the 4 tables ?
Can you show the code you are using to fill the 5th table ?
sajeelabbasi 11-Mar-14 12:44pm    
if (isset($_REQUEST['submit']))
{
$s_name = $_REQUEST['s_name'];
$f_name = $_REQUEST['f_name'];
$gender = $_REQUEST['gender'];
$cnic = $_REQUEST['cnic'];
$email = $_REQUEST['email'];
$c_name = $_REQUEST['c_name'];
$d_name = $_REQUEST['d_name'];
$faculty_name = $_REQUEST['faculty_name'];
$program = $_REQUEST['p_name'];
$session = $_REQUEST['session'];
$section = $_REQUEST['section'];
$semester = $_REQUEST['semester'];
$roll_no = $_REQUEST['roll_no'];
$h_name = $_REQUEST['h_name'];
$floor= $_REQUEST['floor'];
$wing= $_REQUEST['wing'];
$room_no= $_REQUEST['room_no'];
$laptop = $_REQUEST['laptop'];
$pc = $_REQUEST['pc'];
$mobile = $_REQUEST['mobile'];
$ip_laptop = $_REQUEST['ip_laptop'];
$ip_pc= $_REQUEST['ip_pc'];
$ip_mobile = $_REQUEST['ip_mobile'];
$mac_laptop= $_REQUEST['mac_laptop'];
$mac_pc= $_REQUEST['mac_pc'];
$mac_mobile = $_REQUEST['mac_mobile'];
$total = $_REQUEST['total_system'];

$sql = "INSERT INTO student SET s_name='$s_name', f_name='$f_name' ,gender='$gender', email='$email', cnic='$cnic'" ;
$sql = "INSERT INTO campus SET c_name='$c_name'" ;
$sql = "INSERT INTO faculty SET faculty_name='$faculty_name'" ;
$sql = "INSERT INTO department SET d_name='d_name'";
$sql = "INSERT INTO hostel SET h_name='$h_name'" ;
$sql = "INSERT INTO program SET p_name='$program', session='$session' , section='$section', semester='$semester'
, roll_no='roll_no'" ;
$sql = "INSERT INTO assign_hostel SET floor='$floor', wing='$wing' , room_no='$room_no'" ;
$sql = "INSERT INTO assign_system SET type_laptop='$laptop', type_pc='$pc' , type_mobile='$mobile', ip_laptop='$ip_laptop', ip_pc='$ip_pc' , ip_mobile='$ip_mobile',mac_laptop='$mac_laptop', mac_pc='$mac_pc' , mac_mobile='$mac_mobile',total_system='$total'" ;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900