Hi guys,
I am programming an Android App and I am trying to do a multiple SQL insert but it doesn't work. Can someone help me? And I also want to have the ID from the new created student. How do I get that ?
<?PHP
if($_SERVER['REQUEST_METHOD']=='POST'){
$Name = $_POST['Name'];
$Surname = $_POST['Surname'];
$Street = $_POST['Street'];
$City = $_POST['City'];
if($Name == '' || $Surname == '' || $Street == '' || $City == ''){
echo 'Please fill all values';
}else{
require_once('dbConnect.php');
$sql = "INSERT INTO T_Student(Name,Surname,Street,City,F_ID_Teacher) VALUES('$Name','$Vorname','$Strasse', '$Plz','2')";
$sql .= "INSERT INTO T_Class(Subjekt,Number,F_ID_Student) VALUES('','','I WANT HERE THE ID FROM THE NEW CREATED STUDENT')";
$sql .= "INSERT INTO T_School(Name,Street,City,F_ID_Student) VALUES('','','','I WANT HERE THE ID FROM THE NEW CREATED STUDENT')";
if(mysqli_multi_query($con,$sql)){
echo 'Added Student';
}else{
echo 'Error! Try again';
}
}
mysqli_close($con);
}
?>