When you insert a record, you may need to track the id of that inserted record and use it in another table straight after.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$sql = "INSERT INTO phonecalls (clientid,name) VALUES ('$clientid','$name')"; if ($mysqli->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $sql->error; } //if your connection code is this ($mysqli) //$mysqli = new mysqli('localhost', 'root', 'password', 'dbname'); // then use that in the variable below echo "ID of last inserted record is: " . mysqli_insert_id($mysqli); |