<?php
if (!isset($_POST['submit']))
$TheName = $_POST['TheName'];
$host = "localhost";
$user = "root";
$pass = "";
$db = "onlinebookclub";
$link = mysqli_connect($host, $user, $pass, $db);
$query = "SELECT * FROM author WHERE name = $TheName";
//3.excute SQL query
$result = mysqli_query($link, $query) or die('Error querying database');
//5. Close Connection
mysqli_close($link);
//4. process the result
?>
<html>
<head>
<hr>
<title></title>
</head>
<body>
<?php if (!empty($row)) {
while ($row = mysqli_fetch_array($result)) {
$author_id = $row['author_id'];
$name = $row['name'];
$gender = $row['gender'];
$birth_year = $row['birth_year'];
$introduction = $row['introduction'];
?>
<table>
<tr>
<td>Name: </td>
<td> <?php echo $name; ?><br/></td>
</tr>
<tr>
<td>Author ID: </td>
<td><?php echo $author_id; ?><br></td>
</tr>
<tr>
<td>Gender: </td>
<td><?php echo $gender; ?><br/></td>
</tr>
<tr>
<td>Birth Year: </td>
<td><?php echo $birth_year; ?><br></td>
</tr>
<tr><td><hr/></td>
<td><hr/></td>
</tr>
</table>
<?php
}
}else {
echo "No records found";
}
?>
</body>
</html>
My PHP file is not retreiving the proper data. It is supposed to retrieve the relevant details from my database but all it has been showing is No records found. How can I fix this? I tried moving the close link to the end but the error is still there.