我有一个昨天工作的网页。 这是一个非常基本的页面,里面有一个非常简单的php表。 但是我今天尝试添加另一个列,现在页面将不会加载它甚至在我检查网页元素时都不显示代码。 当我将index.php重命名为index.html时会显示,但当然php表不起作用。 任何帮助,将不胜感激。 此外,我尝试了一个不同的index.php页面,它的工作原理
这是我的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 * FROM `prices` ORDER BY `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(); ?>I have a webpage that was working yesterday. It is a very basic page that has a very simple php table in it. However i attempted to add another column today and now the page won't load it doesn't even show the code when i inspect the element of the webpage. It will display when I rename the index.php to index.html but then of course the php table doesn't work. Any help would be appreciated. Also I tried a different index.php page and it worked
Here is my 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 * FROM `prices` ORDER BY `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(); ?>最满意答案
您没有在循环中连接字符串:
$row ["Quantity"]"</td></tr>";应该
$row ["Quantity"] . "</td></tr>";要在将来跟踪这些错误,请参阅: 如何显示PHP错误?
You aren't concatenating a string in the loop:
$row ["Quantity"]"</td></tr>";Should be
$row ["Quantity"] . "</td></tr>";For tracking down these errors in the future see: How do I get PHP errors to display?
更多推荐
php,index,echo,page,电脑培训,计算机培训,IT培训"/> <meta name="descripti
发布评论