Reputation: 2645
What is the problem with my code?
$sql = "select username,num from login order by num desc";
$result = $conn->query($sql);
$rnk=1;
if ($result->num_rows > 0) {
while($row = mysqli_fetch_array($result)){
echo "<tr><td>";
echo $row["username"];
echo "</td><td>";
echo $row["num"];
echo "</td><td>";
echo $rnk;
echo "</td></tr>"
}
} else {
echo "0 results found";
}
$conn->close();
I had placed the above code after providing necessary connection codes between table element in my html page with .php extension. When i call the page it shows only a blank page. Its not even showing the table headers.
Upvotes: 1
Views: 115
Reputation: 898
Try this one
$sql = "select username,num from login order by num desc";
$result = $conn->query($sql);
$rnk=1;
if ($result->num_rows > 0) {
echo "<table>";
while($row = mysqli_fetch_array($result)){
echo "<tr><td>".($row['username'])."</td>";
echo "<td>".($row['num'])."</td>";
echo "<td>".($rnk)."</td></tr>";
}
echo "</table>";
} else {
echo "0 results found";
}
$conn->close();
Upvotes: 1
Reputation: 32748
Crank up PHP error reporting so you can see what the real problem is.
http://php.net/manual/en/errorfunc.configuration.php#ini.error-reporting
Also look in the Apache error.log
to see what, if any, errors are being logged. Assuming you are using Apache
Upvotes: 0