i have webpage working yesterday. basic page has simple php table in it. attempted add column today , page won't load doesn't show code when inspect element of webpage. display when rename index.php index.html of course php table doesn't work. appreciated. tried different index.php page , worked
here php:
<?php $servername = "ip"; $username = "username"; $password = "password"; $dbname = "prices"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $sql = "select * `prices` order `prices`.`name` asc"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table><tr><th>name</th><th>price in $||</th><th>price in ref</th><th>quantity</th></tr>"; // output data of each row while($row = $result->fetch_assoc()) { echo "<tr><td>" . $row["name"]. "</td><td>" . $row["price"]. "</td><td>" . $row["price_in_metal"]. "</td><td>" . $row ["quantity"]"</td></tr>"; } echo "</table>"; } else { echo "0 results"; } $conn->close(); ?>
you aren't concatenating string in loop:
$row ["quantity"]"</td></tr>"; should
$row ["quantity"] . "</td></tr>"; for tracking down these errors in future see: how php errors display?
Comments
Post a Comment