sahromo 0 Newbie Poster

i have this table named room that contains the RoomNo as the primary key and it needs to pass the primary key to a foreign key in another table called AF and RoomNo as its foreign key. then another table called facilities and FNO as its primary key, it also sends FNO to the table AF and FNO as its foreign key. i've got this code, but its not working.. HELP:confused:

<?php
	
if(isset($_POST['submit']))
{

	$username="sah";
	$password="jinjin";
	
	$db=mysql_connect("localhost" , $username, $password);
	if (!$db)
  	{
 	 die('Could not connect: ' . mysql_error());
	}
	mysql_select_db("romo_res", $db);	

	
	$Desc = $_POST['Desc'];
	$QTY = $_POST['QTY'];
	$RentFee = $_POST['RentFee'];

	
	$sql = "INSERT INTO `facilities` (`Desc` , `QTY` , `RentFee`)
	VALUES ('$Desc', '$QTY', '$RentFee')";
	$af = "SELECT facilities.FNO, facilities.QTY FROM facilities INNER JOIN facilities ON af.FNO = facilities.FNO ON af.QTY = facilities.QTY;";

	
	if (!mysql_query($sql,$db))
  	{
  	die('Error: ' . mysql_error());
  	}
	mysql_query($af);
	mysql_close($db);
}
?>

<--for the room table

<?php
	
if(isset($_POST['submit']))
{

	$username="sah";
	$password="jinjin";
	
	$db=mysql_connect("localhost" , $username, $password);
	
	mysql_select_db("romo_res", $db);	

	
	$Class = $_POST['Class'];
	$Beds = $_POST['Beds'];
	$Price = $_POST['Price'];
	$Capacity = $_POST['Capacity'];

	
	
	$sql = "INSERT INTO room (Class , Beds , Price , Capacity)
	
	VALUES ('$Class', '$Beds', '$Price', '$Capacity')";
	
	$af = "SELECT room.RoomNo FROM room INNER JOIN room ON af.RoomNo = room.RoomNo;";

	mysql_query($sql);
	mysql_query($af);
}
?>

<--for the facilities table..

please, i need help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.