I'm following along with the example from w3schools to extract some rows from a mysql db and return the results in a table format, but I'm only getting blank rows (although the correct number of them, oddly enough).
Here is what I have in my php script:
<!DOCTYPE html>
<html>
<head>
<style>
table
{
width: 100%;
border-collapse: collapse;
}
table, td, th
{
border: 1px solid black;
padding: 5px;
}
th
{
text-align: left;
}
</style>
</head>
<body>
<?php
$q = $_GET['q'];
$con = mysqli_connect('localhost', 'root', '123', 'drugsatfda');
if (!$con) {die('Could not connect: ' . mysqli_error($con));}
mysqli_select_db($con, "drugsatfda");
$sql="SELECT * FROM products WHERE DrugName LIKE '"."%".$q."%"."'";
$result = mysqli_query($con,$sql);
$count = 0;
echo "<table>
<tr>
<th>Application Number</th>
<th>Product Number</th>
<th>Form</th>
<th>Strength</th>
<th>Reference Drug</th>
<th>Drug Name</th>
<th>Active Ingredient</th>
</tr>";
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC) && $count < 10) {
echo "<tr>";
echo "<td>" . $row['ApplNo'] . "</td>";
echo "<td>" . $row['ProductNo'] . "</td>";
echo "<td>" . $row['Form'] . "</td>";
echo "<td>" . $row['Strength'] . "</td>";
echo "<td>" . $row['ReferenceDrug'] . "</td>";
echo "<td>" . $row['DrugName'] . "</td>";
echo "<td>" . $row['ActiveIngredient'] . "</td>";
echo "</tr>";
$count++;
}
echo "</table>";
mysqli_close($con);
?>
</body>
</html>
Can someone please help me see where I'm going wrong?