I have a PHP file which is designed to link to a test SQL table which I've set up. The problem is that entering data into my search box isn't getting the results I'm after.
First, the PHP code:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT ID, FirstName, LastName FROM 'create'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result)>0) {
// output data of each row
while($row=mysqli_fetch_assoc($result)) {
echo "ID: " . $row["ID"]. " - Name: " . $row["FirstName"]. " " . $row["LastName"]. "<br>";
}
} else {
echo "0 results";
}
mysqli_close($conn);
?>
And the SQL file, copied and pasted from the CSV version, in order of ID, FirstName, LastName...
1,"Ryan","Butler"
2,"Ryan","Butler"
3,"Brent","Callahan"
4,"Harry","Callahan","makemyday@dirtyharry.net"
5,"Luke","Cage","luke@mywifeisdead.com",
6,"Jessica","Jones","jessica@getkilgrave.org",
The result of entering any of the above words in my search box should give me a result of 6. Jessica. Jones. (I'm not bothering to search for the emails, I don't know why I included them.) Instead, I get "0 results" no matter what I type.
There's probably just one thing that I have wrong, but I'll be damned if I know what it is. Then again, PHP is not my forté.