In my while loop I am able to correctly do the first part of the if statement but the ELSE will not work, I can get everything to work correctly so I get the string and I match it against the string in the db and if the string is correct I get the correct output too but if the string does not match I can't get the else statement to work so to just echo out that the string does not match.
if(isset($_POST['submit'])) {
$search_query = escape_string($_POST['search_query']);
$query = "SELECT client_id, client_name, status FROM clients WHERE client_id = '".$search_query."' ";
$result = mysqli_query($connection, $query);
if($result && !empty($search_query)) {
while($code = mysqli_fetch_assoc($result)) {
if($_POST['search_query'] === $code['client_id']) {
echo $code['client_name'] . " " . $code['client_id'] . " " . $code['status'];
} else {
echo $_POST['search_query'] . " ID does not exist!";
}
}
}
}
This is the form:
<form action="search.php" method="post">
<p>
<input type="text" name="search_query" id="search" />
<input type="submit" name="submit" value="SEARCH" />
</p>
</form>
$_POST['search_query']and$code['client_id']?