Hi
I am new to php mysql. Here is the problem I am having:
I run the below mysql select statement, it give the following results:
q column answer
what is your name? jon
what is your name? ken
what is your name? Rob
where do you live? UK
where do you live? US
where do you live? Ireland
I want my query to display one question with three possible answers, example.
what is your name? jon ken rob
where do you live? UK US Ireland
I am not sure if I should be using a for loop. I am new to this and finding it really hard.
Thanks in advance for you help.
$query = "select questions.question as q, answers.answer from questions,answers where questions.questionID = answers.questionID";
$result = mysql_query($query); // run the query
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
for($i=0;$i <=3;$i++) {
$i = $row['q'];
}
echo '<tr>
<td align="left">' . $i . ':</td>
<td align="left">'. $row['answer'] .'</td>
</tr>';
}
I am new to php mysql. Here is the problem I am having:
I run the below mysql select statement, it give the following results:
q column answer
what is your name? jon
what is your name? ken
what is your name? Rob
where do you live? UK
where do you live? US
where do you live? Ireland
I want my query to display one question with three possible answers, example.
what is your name? jon ken rob
where do you live? UK US Ireland
I am not sure if I should be using a for loop. I am new to this and finding it really hard.
Thanks in advance for you help.
$query = "select questions.question as q, answers.answer from questions,answers where questions.questionID = answers.questionID";
$result = mysql_query($query); // run the query
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
for($i=0;$i <=3;$i++) {
$i = $row['q'];
}
echo '<tr>
<td align="left">' . $i . ':</td>
<td align="left">'. $row['answer'] .'</td>
</tr>';
}