Please Guys what must be wrong with this my code, I have tried to fetch the search data from my Database as follows
Students DATA As follow
Reg Number: Full Name: Faculty: Program: Level: Group.
on the HTML Search Page
<html>
<h2> Enter your matric number to connect to others studying your course </h2>
<form action="demo.php" method="post">
<b> ReG </b><input type="text" Name="find">
<input type="submit" value="Submit" />
</form>
</html>
PHP SIDE
<table border="1">
<tr>
<th>Student Full Name</th>
<th> Faculty</th>
<th> Program</th>
<th> Entry Year</th>
<th> Study Group</th>
<th> Group Members Contact</th>
<th> Group Leader Contacts</th>
</tr>
<?php
$conn=mysqli_connect("localhost", "root", "", "student");
// Check connection
if($conn=== false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$q = $_POST['find'];
if ($q == "")
{
echo "<p>You forgot to enter a search term!!!";
exit;
}
$sql = "SELECT * FROM study_circle WHERE matric LIKE $q ";
$result = mysqli_query($conn, $sql);
if ($result)
{
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>";
echo $row['full_name'];
echo "</td>";
echo "<td>";
echo $row['faculty'];
echo "</td>";
echo "<td>";
echo $row['program'];
echo "</td>";
echo "<td>";
echo $row['entry_year'];
echo "</td>";
echo "<td>";
echo $row['study_group'];
echo "</td>";
echo "<td>";
echo $row['group_members'];
echo "</td>";
echo "<td>";
echo $row['group_leader'];
echo "</td>";
echo "</tr>";
echo "<br/>";
}
} else {
echo "0 results";
}
mysqli_close($conn);
?>
Each time I try it it's bringing Empty results even though I have populated the database
Right now it's on my Localhost system, please anyone good person to help, am just new to Programming. I will be happy to fix this