Hi.
I am not sure why i am having such a problem with this. I want to check a query and if it matches data in the last name column I want to print the data. However, if there is no match i want it to echo an error and end. Im sure this is probably a typo somewhere but I do not see it. Hope fully one of you will.
Thanks
PHP Code:$query = "SELECT * FROM main WHERE last = '$lastname'";
if ($result = $mysqli->query($query)){
while ($obj = $result->fetch_object()) {
printf ('<div class="name">'."%s", $obj->last);
printf ("%s", $obj->first);
printf ("%s", $obj->voter_id);
printf ("%s", $obj->dob);
printf ("%s", $obj->city .'</div>');
}
}
else{
echo 'There is no person in your database by that last name.';
$mysqli->close();
exit;
}




Reply With Quote


Bookmarks