Re: PHP + MySQL results
Hi! I think it have to work, but I didn't check it, so..........
$query = "SELECT q.qID, q.qQuestion, a.aAnswer from qQAnswers s, qAnswers a, qQuestions q WHERE s.qaAID = a.aID AND q.qID = s.qaQID ORDER BY q.qID";
$result = mysql_query($query, $descriptor);
unset($result_arr);
if(mysql_num_rows($result) > 0)
{
while ($row = mysql_fetch_row($result))
{
if(isset($result_arr[$row[0]]))
{
$result_arr[$row[0]]['answer'][] = $row[2];
}
else
{
$result_arr[$row[0]]['question'] = $row[1];
$result_arr[$row[0]]['answer'][0] = $row[2];
}
}
foreach($result_arr as $id=>$arr)
{
echo $id.') '.$arr['question'].' ? ';
foreach($arr['answer'] as $value)
echo $value.' ';
echo "\n";
}
Subject
Written By
Posted
Re: PHP + MySQL results
July 21, 2005 12:15AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.