Hello,
I am using while loops within while loops to display relational information from multiple tables (why there is no views support in mysql?!?).
But it seems that after a particular number of iterations the results from queries seems to be failing.
Is it possible, or am i doing smt wrong?
example code segment i am using.
$qryMain = "SELECT * FROM messages WHERE forumid=$fid AND refid=0 ORDER BY post LIMIT $qrylimit,20";
$rsMain = mysql_db_query ( $db, $qryMain );
$qryFrom = "SELECT id FROM users WHERE username='$uid'";
$rsFrom = mysql_db_query ( $db, $qryFrom );
while ( $prow = mysql_fetch_object ($rsMain) ) {
$messageID = $prow->id;
$senderID = $prow->fromid;
echo $prow->subject;
while ( $frow = mysql_fetch_object ($rsFrom) ) {
$fromID = $frow->id;
$qrySender = "SELECT name, surname FROM alumni WHERE id=$fromID";
$rsSender = mysql_db_query ( $db, $qrySender );
while ( $srow = mysql_fetch_row ($rsSender) ) {
echo $srow->name;
echo $srow->surname;
}
}
echo $prow->post;
}
I am using while loops within while loops to display relational information from multiple tables (why there is no views support in mysql?!?).
But it seems that after a particular number of iterations the results from queries seems to be failing.
Is it possible, or am i doing smt wrong?
example code segment i am using.
$qryMain = "SELECT * FROM messages WHERE forumid=$fid AND refid=0 ORDER BY post LIMIT $qrylimit,20";
$rsMain = mysql_db_query ( $db, $qryMain );
$qryFrom = "SELECT id FROM users WHERE username='$uid'";
$rsFrom = mysql_db_query ( $db, $qryFrom );
while ( $prow = mysql_fetch_object ($rsMain) ) {
$messageID = $prow->id;
$senderID = $prow->fromid;
echo $prow->subject;
while ( $frow = mysql_fetch_object ($rsFrom) ) {
$fromID = $frow->id;
$qrySender = "SELECT name, surname FROM alumni WHERE id=$fromID";
$rsSender = mysql_db_query ( $db, $qrySender );
while ( $srow = mysql_fetch_row ($rsSender) ) {
echo $srow->name;
echo $srow->surname;
}
}
echo $prow->post;
}