Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP表仅显示一行_Php_Mysql_Sql_Mysqli - Fatal编程技术网

PHP表仅显示一行

PHP表仅显示一行,php,mysql,sql,mysqli,Php,Mysql,Sql,Mysqli,我在从MySQL表中检索数据时遇到问题。我的脚本只检索一行,这是我的表中的最后一行,其中该表包含12个填充行。我的目标是检索表中的所有行 以下是代码的一部分,我认为问题源于: <?php //Grabs the whole queston list $question_list=""; $sql = mysqli_query($link,"SELECT * FROM DebateQuestion") or die(mysql_error());; $questionCount = mysq

我在从MySQL表中检索数据时遇到问题。我的脚本只检索一行,这是我的表中的最后一行,其中该表包含12个填充行。我的目标是检索表中的所有行

以下是代码的一部分,我认为问题源于:

<?php
//Grabs the whole queston list
$question_list="";
$sql = mysqli_query($link,"SELECT * FROM DebateQuestion") or die(mysql_error());;
$questionCount = mysqli_num_rows($sql);// count the output amount

if($questionCount>0){
while($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){
$id = $row["qQuestionNo"];
$question = $row["qQuestion"];
$venue = $row["qDebateVenue"];
$date = $row["qDate"];
$question_list = "$id. $question&nbsp;&nbsp;&nbsp;<a href='#'>Edit</a> &bull;<a href='#'>Delete</a><br/>";
}
}else{
$question_list = "There are no questions in the inventory yet";
}

?>

您的错误如下:

$question_list = "$id. $question&nbsp;&nbsp;&nbsp;<a href='#'>Edit</a> &bull;<a href='#'>Delete</a><br/>";

非常感谢。这几天我一直在想办法解决这个问题。快速提问在将变量
$question\u list
初始化为空字符串的第一行,短语“确保追加文本”是什么意思,这很好!在对表行进行迭代期间(在
while
中),您希望填充此变量。这是通过为表的每一行追加HTML(在已经存在的内容末尾添加)来完成的。这是通过
=
完成的。您的代码只是在每次迭代中覆盖以前的内容,因此您最终只得到最后一条记录非常感谢。。。要点
$question_list .= "$id. $question&nbsp;&nbsp;&nbsp;<a href='#'>Edit</a> &bull;<a href='#'>Delete</a><br/>";