My PHP query is returning zero results when the table has 10 rows. What is actually displayed is a portion of the PHP table formatting code.
ACTUAL OUTPUT:
0) { // output data of each row while($row = mysql_fetch_assoc($result)) { echo "in: " . $row["in"]. " - Name: " . $row["Name"]. " - Email: " . $row["Email"]. "
"; } } else { echo "0 re
sults"; } mysql_close($conn);?
HTML/PHP CODE:
<div class="about-text">
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "db";
// Create connection
$conn = mysql_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysql_connect_error());
}
$sql = "SELECT * FROM tablename";
$result = mysql_query($conn, $sql);
if (mysql_num_rows($result) > 0) {
// output data of each row
while($row = mysql_fetch_assoc($result)) {
echo "in: " . $row["in"]. " - Name: " . $row["Name"]. " - Email: " . $row["Email"]. "<br>";
}
} else {
echo "0 results";
}
mysql_close($conn);
?>
</div>