Nathan Caddell Nathan Caddell - 1 year ago 75
HTML Question

HTML Table using PHP MySQLi

I am trying to display some information into a table (HTML Table) with PHP MySQLi. I am currently getting an error on the webpage I created. The image shows the image of my page and error.

enter image description here

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "ip_site_database_project";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
$sql = "SELECT * FROM site";
$result = mysqli_query($conn, $sql);

echo "<table border='1' align ='center'>";
echo "<tr>";
echo "<td>Site ID</td>";
echo "<td>Site Name</td>";
echo "<td>Site Type</td>";
echo "<td>Description</td>";
echo "<td>Site Dial Code</td>";
echo "<td>Site Number Range (Start)</td>";
echo "<td>Site Number Range (End)</td>";
echo "<td>Site Active Since</td>";
echo "<td>Site Ceased Date</td>";
echo "</tr>";
while($rowitem = mysqli_fetch_array($results))
echo "<td>" . $rowitem[Site_ID] . "</td>";
echo "<td>" . $rowitem[Site_Name] . "</td>";
echo "<td>" . $rowitem[Site_Type] . "/td>";
echo "<td>" . $rowitem[Description] . "</td>";
echo "<td>" . $rowitem[Site_Dial_Code] . "/td>";
echo "<td>" . $rowitem[Site_Number_Range_Start] . "</td>";
echo "<td>" . $rowitem[Site_Number_Range_End] . "/td>";
echo "<td>" . $rowitem[Site_Active_Since] . "</td>";
echo "<td>" . $rowitem[Site_Ceased_Date] . "/td>";
echo "</tr>";



Answer Source

Change this: while($rowitem = mysqli_fetch_array($results)) to this: while($rowitem = mysqli_fetch_array($result))

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download