I am inputting data into MySQL tables using PHP forms and displaying the table when requested (this must be done using MySQLi).
I managed to insert the data without a problem, but I am having trouble displaying the table using MySQLi and PHP. I need to display the results in an XHTML table.
I tried to follow tutorials I found online, but they dont seem to work; my current code displays the header, and then a blank row beneath it instead of the data in my table.
I know it connect and like I said, it is able to insert. Could someone please show me (and explain please) how I would solve my issue?
$query = "select * from $table_name;";
if ($result = mysqli_query($db_link, $query)){
echo "<table>";
//header
echo "<tr><td>Date Added</td>";
echo "<td>Name</td>";
echo "<td>Email</td>";
echo "<td>Gender</td>";
echo "<td>Country</td>";
echo "<td>Subject</td>";
echo "<td>Comment</td>";
echo "<td>Subscription</td></tr>";
//data
while ($row = $result->fetch_row()) {
$Row = mysqli_fetch_assoc($result);
echo "<tr><td>{$Row[0]}</td>";
echo "<td>{$Row[1]}</td>";
echo "<td>{$Row[2]}</td>";
echo "<td>{$Row[3]}</td>";
echo "<td>{$Row[4]}</td>";
echo "<td>{$Row[5]}</td>";
echo "<td>{$Row[6]}</td>";
echo "<td>{$Row[7]}</td></tr>";
}
echo "</table>";
}
mysqli_free_result($result);
mysqli_close($db_link);