I'm very new to MySQL and PHP. I have two tables. The first one is users
which has the information for the site users and the second table is called SendRequests
.
I want to store the data each user posts (it's like an ad posting site) in the second table where I want the first column to be for the email of the logged-in user so I can find the posts from that user later. This is how I am trying to do it:
Using two INSERT
s as follows:
$query1=" INSERT INTO SendRequests (email) SELECT email FROM users
WHERE id = '".$_SESSION['id']."' LIMIT 1";
mysqli_query($link, $query1);
$_SESSION['id']= mysqli_insert_id($link);
$query = "INSERT INTO `SendRequests` (`country`, `city`, `fee`) VALUES
('".mysqli_real_escape_string($link,$_POST['departurecountry'])."',
'".mysqli_real_escape_string($link, $_POST['departurecity'])."',
'".mysqli_real_escape_string($link,$_POST['fee'])."')."')
WHERE id = '".$_SESSION['id']."'";
mysqli_query($link, $query);