我想,以顯示它內部的所有的值的表,但目前還沒有顯示的值,僅創建一個空表PHP表中未顯示的內容,只有創建表盒
[什麼表顯示爲(圖像)] [1]
$result = mysqli_query($conn,'SELECT * FROM Pictures ');
$conn->close();
的Html
<html>
<table border="2" style= "background-color: #84ed86; color: #761a9b; margin: 0 auto;"
<thead>
<tr>
<th>id</th>
<th>Name</th>
<th>image</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
if($result != null){
結果不爲空
while($row1 = mysqli_fetch_assoc($result)){
foreach ($row1 as $row){
?>
<tr>
<td><?php $row['id'] ?></td>
<td><?php $row['hname'] ?></td>
<td><?php $row['himage'] ?></td>
<td><?php $row['hdesc'] ?></td>
</tr>
<?php
}
}
}else{
echo "Something went wrong with the result";
}
?>
</tbody>
</table>
<?php //mysqli_close($conn); ?>
</body>
</html>
改變了出來放到你給出的答案一致,但輸出出來的畫面2,而我的表實際上是圖片3個任何想法 output:
有你嘗試使用<?= $ row ['id']?>來表示你真正想要的打印它?你也可以使用「回聲」或「打印」。只是輸入一個變量名並不意味着你想要打印它。 – EdmCoff
你爲什麼要創建一個'foreach'循環?這是沒有必要的。 – Samuel
你只是缺少'echo'函數:'<?php echo $ row ['id']?>' –