Reputation: 161
I have a problem in retrieving data from my MySQL table. My script only retrieves one row, which is the last row from my table, wherein the table contains 12 filled rows. My aim is to retrieve all rows in the table.
Here is the section of the code I believe the problem stems from:
<?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 <a href='#'>Edit</a> •<a href='#'>Delete</a><br/>";
}
}else{
$question_list = "There are no questions in the inventory yet";
}
?>
Upvotes: 0
Views: 737
Reputation: 929
Your error is here:
$question_list = "$id. $question <a href='#'>Edit</a> •<a href='#'>Delete</a><br/>";
Make sure you append the text, not overwrite the previous value! Use .=
to append strings:
$question_list .= "$id. $question <a href='#'>Edit</a> •<a href='#'>Delete</a><br/>";
Upvotes: 2