I am trying to store the result from an sql query into a variable in my php query. But thing is, it is not working, simply because I am making schoolboy errors and due to my lack of experience in php.
This is my code:
<?php
if(!empty($_POST['driverNo'])){
$driverNoText = $_POST['driverNo'];
$stmt = "SELECT registrationNo FROM cars WHERE driverNo = ?";
$result = $conn->prepare($stmt);
$result->bind_param('s', $driverNoText);
$result->execute();
$result->store_result();
if($result->num_rows > 0){
$registrationNo = $result["registrationNo"];
echo $registrationNo;
}
else{
$registrationNo = "";
}
}
else{
echo "Something went horribly wrong";
}
?>
I just want to store the registrationNo into the $registrationNo, because I need to use that value elsewhere later.
Would mean a lot if someone could help me fix my error
Thanks