I have two queries that I want to run. The result should be that the rows of dilemmas/questions are listed with the answers below the questions. The answers are hidden though by javascript until I choose to press the image-button, which should then show the answer that belongs to the chosen question.
The code:
$result = mysqli_query($mysqli,"SELECT rid, pid, qid, aid, points FROM result WHERE rid=$val");
$answertext = mysqli_query($mysqli, "SELECT answer FROM answer_det WHERE pid=(SELECT pid FROM result WHERE rid=$val) AND qid=(SELECT qid FROM result WHERE rid=$val) AND aid=(SELECT aid FROM result WHERE rid=$val)");
while($row = mysqli_fetch_array($result) AND $row2 = mysqli_fetch_array($answertext))
{
$resultp = $row['points'];
$color = "#000000";
if (($resultp >= 1) && ($resultp <= 3))
$color = "#FF0000";
else if (($resultp >= 3) && ($resultp <= 6))
$color = "#FF9900";
else if (($resultp >= 6) && ($resultp <= 10))
$color = "#07d407";
echo "<div class='question-wrap'>
<b><small>Dilemma ".$row['qid']." - Answer ". $row['aid'].": </small><span style=\"color: $color\">". $resultp."</span></b> of <b>10 <small>Points</small></b>
<input type='image' class='answer-toggle' title='Information' src='img/down.png' width='13' height='10'>
<p class='answer'>". $row2['answertext']."</p></div>"; }
I can't figure out what is wrong. This is the message I get:
Warning: mysqli_query(): (21000/1242): Subquery returns more than 1 row in D:\home\site\wwwroot\devlopmentespondent2.php on line 122 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in D:\home\site\wwwroot\devlopmentespondent2.php on line 125
This is line 122:
$answertext = mysqli_query($mysqli, "SELECT answer FROM answer_det WHERE pid=(SELECT pid FROM result WHERE rid=$val) AND qid=(SELECT qid FROM result WHERE rid=$val) AND aid=(SELECT aid FROM result WHERE rid=$val)");
This is line 125:
while($row = mysqli_fetch_array($result) AND $row2 = mysqli_fetch_array($answertext))