I am currently trying to output a the results of a MySQL table in PHP. I have a general understanding of web based programming but not enough to debug my code. I know the SQL is good, and the database is linked to my site it's just a matter of making it post to a table. I will post the code and would appreciate some help:
<?php
$sql = "SELECT player_name AS 'Name',
position AS 'Position',
team AS 'Team',
opp AS 'Opponent'
FROM `dbname`
WHERE position = 'QB'";
$stmt = $db->query($sql);
if($stmt-> num_rows > 0) {
echo "<table class='table'>";
echo "<thead class='thead-inverse'>";
echo "<tr><th>Name</th><th>Position</th><th>Team</th><th>Opponent</th>";
echo "</thead>";
echo "<tbody>";
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<tr><td>";
echo $row['Name'];
echo "</td><td>";
echo $row['Position'];
echo "</td><td>";
echo $row['Team'];
echo "</td><td>";
echo $row['Opponent'];
echo "</td></tr>";
}
echo "</tbody>";
echo "</table>";
}
else {
echo "No Results";
}
All that I get from this is a no results output.