作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我现在有这段代码,我只获取最后两行,但我需要使用 html 获取数据库中的尽可能多的行。预先感谢您
//We include the includes.php, which contains our db connection data.
include("includes.php");
//dbCon(); references the db connection data in includes.php - in other words we call a function.
dbCon();
$query = "SELECT * FROM product WHERE categoryid = 1;";
$result = mysqli_query($dbc,$query) or die('Error querying database.');
if (mysqli_num_rows($result) == NULL) {
mysqli_close($dbc);header("Location:index.php?l=f");exit();
}
while ($row = mysqli_fetch_assoc($result)){
$name = $row['name'];
$price = $row['price'];
}
echo "<input type='checkbox' name='name' value='name'>".$name."</br>";
echo "Price: "." "."<strong>".$price."</strong></br>";
最佳答案
将 echo 移至循环内部
while ($row = mysqli_fetch_assoc($result)){
$name = $row['name'];
$price = $row['price'];
echo "<input type='checkbox' name='name' value='name'>".$name."</br>";
echo "Price: "." "."<strong>".$price."</strong></br>";
}
关于php - 如何回显整个表格?现在我只得到最后一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20399434/
我是一名优秀的程序员,十分优秀!