gpt4 book ai didi

PHP如何从表中获取所有数据并将其相应地放入div中

转载 作者:行者123 更新时间:2023-11-29 06:01:33 26 4
gpt4 key购买 nike

我的数据库中有很多表,每个表都有特定的按钮,所以当我单击其中一个按钮时,它应该在 div 中显示表的行和列,但它不能正确显示例如

注意:每张表都有不同的数字列和不同的数字行

This is what it looks like
This is what i want, for each of the table

$query = "SELECT * FROM ghousn.$table";
$result = mysqli_query($connection, $query);
echo" <table >";
while($row = mysqli_fetch_assoc($result)){
foreach($row as $key => $val){
echo "<tr>";
echo"<th>$key</th>
</tr>
<tr>
<td>$val</td>


</tr>";
}
}
echo "</table>";


}

最佳答案

$query = "SELECT * FROM FROM ghousn.$table";
$result = mysqli_query($connection,$query);
echo" <table border='1' >";

while($row = mysqli_fetch_assoc($result)){
echo "<tr>";
foreach($row as $key => $val){
echo"<th>$key</th> ";
}
echo "</tr>";
echo"<tr>";
foreach($row as $key => $val){
echo "<td>$val</td>";
}
echo "</tr>";
}

echo "</table>";

关于PHP如何从表中获取所有数据并将其相应地放入div中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44475446/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com