I am building a website for myself (learning). I am trying to use .html for the base:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>JPeG & Chaos LLP - Repair Status</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<div class="menubar">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="services.html">Services</a></li>
<li><a href="status.html">Repair Status</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html">Contact Us</a></li>
</ul>
</div>
<header>JPeG & Chaos LLP</header>
//XYZ
<p>
blah blah blah blah
</p>
</body>
</html>
Where I put the XYZ, I am wanting to pull a table from mysql and place it in to a table that updates every so many minutes (not concerned about the auto-refresh for now).
I tried adding the following PHP in to my HTML, but it doesn't act like PHP, it just prints the sql scripts :
<?php
$servername = "localhost";
$username = "name";
$password = "pass";
$dbname = "RepairStatus";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, status, tip, eta FROM WorkOrders";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table><tr><th>ID</th><th>Status</th><th>Time In Progress</th><th>Est Time of Completion</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row["id"]."</td><td>".$row["status"]." ".$row["tip"]."</td><td>".$row["eta"]."</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
$conn->close();
?>
the website shows:
num_rows > 0) { echo ""; // output data of each row while($row = $result->fetch_assoc()) { echo ""; } echo "
and continues through the remainder of the php section of the code.
I did run the full php code on a .php file through the website and it pulls the data just fine :
http://jpegchaos.com/rstatus.php
Any suggestions on how to do this so I can use my CSS / HTML to format the results?