I created a form for a user to enter in an employee first name and last name. When the user it submits it has to select everything from the employees database where the entry is like the first_name column in the employees table. When I do that it does not show up on the page so I believe there must be something wrong that I can not find.
<!doctype html>
<html lang="en">
<head>
<link href="employeeStyles.css" rel="stylesheet">
<title>Employee Search</title>
</head>
<body>
<div id="employeeArea">
<h1>Employee Search Results</h1>
<?php
$firstName = $_GET['firstName'];
$lastName = $_GET['lastName'];
$resultsNumber = $_GET['resultsNumber'];
@ $db = new mysqli('localhost','root','','employees');
$firstName = $db->real_escape_string($firstName);
$lastName = $db->real_escape_string($lastName);
$resultsNumber = $db->real_escape_string($resultsNumber);
if (mysqli_connect_errno()){
echo 'Error: Could not connect to the database. Please try again later. </body></html>';
exit;
}
$query = "SELECT * FROM employees WHERE first_name LIKE .$firstName.'%'";
$result = $db->query($query);
$numResults = $result->num_rows;
echo 'Number of results found '.$numResults;
for ($i=0; $i<$result; $i++){
$row = $result->fetch_assoc();
echo $row ['first_name']."<br>";
echo $row ['last_name']."<br>";
echo $row ['emp_no']."<br>";
echo $row ['hire_date']."<br>";
echo $row ['birth_date']."<br>";
echo $row ['gender']."<br>";
}
$db->close();
?>
</div>
</body>