Here is the procedure: I'm getting:
Fatal error: Cannot break/continue 2 levels in d:\apache\htdocs\gamesite_dev\admin\show_messages.phtml on line 12
This is a function that recurses through a message board database. I pass in the connection, the message id and the level of the message in the recursion.
#---------------------begin snipet---------#
function print_threads($id, $level, $con) {
$sql = "SELECT body, uid, mid, parent_id, m_title, post_time, thread_id FROM mes_board WHERE parent_id='$id' ";
$res = mysql_query($sql, $con) or die ("Couldn't Execute Query");
$num_rows = mysql_num_rows($res);
if ($num_rows == 0) {
//Do Nothing and return
break;
//exit;
} else {
$row = mysql_fetch_row($res);
$parent_id = $row["parent_id"];
$story_id = $row["thread_id"];
$mid =$row["mid"];
$body = $row["body"];
$m_title = $row["m_title"];
$auth_id = $row["uid"];
$post_time = $row["post_time"];
$year = substr($post_time, 0, 4);
$month = substr($post_time, 4, 2);
$day = substr($post_time, 6, 2);
$hour = substr($post_time, 8,2);
$minute = substr($post_time, 10, 2);
$sql_get_poster = "SELECT u_nick, u_email FROM user WHERE uid='$auth_id'";
$sql_get_poster_res = mysql_query($sql_get_poster, $con) or die ("Couldn't execute admin");
$u_row = mysql_fetch_array($sql_get_poster_res);
$u_nick = $u_row["u_nick"];
$u_email = $u_row["u_email"];
if ($parent_id == $story_id) {
$level = 0;
}
//Print shtuff out depending on the level
if ($level == 0) {
$width= 100;
echo "<div align=\"right\"><table border=\"0\" bgcolor=\"#FFFFFF\" width=\"$width%\" cellpadding=\"0\" cellspacing=\"0\"> \n
<TR> \n
<TD BGColor=\"#339900\"> \n
<div class=\"m_title\"> $m_title</DIV> \n
</TD> \n
<TD bgcolor=\"#339900\"> \n
<DIV class=\"post_time\">$month-$day-$year $hour:$minute</DIV>
</TD> \n
</TR> \n
<TR> \n
<TD colspan=\"2\" bgcolor=\"#CACACA\">
<font size=\"1\">Posted By:</font><a href=\"mailto:$u_email\" class=\"admin_email\">$u_nick</a>
</TD>\n
</TR>\n
<TR>\n
<TD colspan=\"2\">\n
$u_nick writes: \"<i> $body</i>\"
</TD>\n
</TR>\n
<TR>
<TD colspan=\"2\"> \n
<a href=\"messageboardpost.phtml?sid=$story_id&pid=$mid\" target=\"new\">Reply to this message</a>\n
</TD>\n
</TR>
</TABLE></div>
";
} else {
$width -= 3;
echo "<div align=\"right\"><table border=\"0\" bgcolor=\"#FFFFFF\" width=\"$width%\" cellpadding=\"0\" cellspacing=\"0\"> \n
<TR> \n
<TD BGColor=\"#339900\"> \n
<div class=\"m_title\"> $m_title</DIV> \n
</TD> \n
<TD bgcolor=\"#339900\"> \n
<DIV class=\"post_time\">$month-$day-$year $hour:$minute</DIV>
</TD> \n
</TR> \n
<TR> \n
<TD colspan=\"2\" bgcolor=\"#CACACA\">
<font size=\"1\">Posted By:</font><a href=\"mailto:$u_email\" class=\"admin_email\">$u_nick</a>
</TD>\n
</TR>\n
<TR>\n
<TD colspan=\"2\">\n
$u_nick writes: \"<i> $body</i>\"
</TD>\n
</TR>\n
<TR>
<TD colspan=\"2\"> \n
<a href=\"messageboardpost.phtml?sid=$story_id&pid=$mid\" target=\"new\">Reply to this message</a>\n
</TD>\n
</TR>
</TABLE></div>
";
}
//end else
mysql_free_result($sql_get_poster_res);
$level += 1;
for ($count = 0; $count < $num_rows; $count++) {
print_threads($mid,$level,$con);
}
}
//END RECURSIVE ELSE
}
//end function