Hello all, I have a problem with the following code. What it is meant to do is query a database table which contains details of various activities and print them to the screen along with a checkbox for the user to tick. Also included in the code is another query to verify whether the user has selected the activity (this information is contained in another table), if so print out the details of the activity with a checked checkbox. $sql = "SELECT * FROM `ifile_Activities` ORDER BY `Activity_Name` ASC"; include("../rms/v2/includes/php/connect.php"); while ($row = mysql_fetch_assoc($rst)) { echo "<table border = '1' width = '541' bordercolor = 'black' cellpadding = '0' cellspacing = '0' bgcolor = 'white'>"; echo "<tr>"; echo "<td>"; echo "<table border = '0' width = '541' bgcolor = 'white'>"; echo "<tr>"; echo "<td>"; echo "<strong><font size = '2'>" . $row['Activity_Name'] . "</font></strong>"; echo "</td>"; echo "<td align = 'right' width = '10'>"; $sql = "SELECT * FROM `ifile_ActivityStudent` WHERE `AS_IF_PU_UPN` = '" . $pu_upn . "' AND `AS_Activity_ID` = '" . $row['Activity_ID'] . "'"; include("../rms/v2/includes/php/connect.php"); $num_rows = mysql_num_rows($rst); if($num_rows == 0) { echo "<input type = 'checkbox' name = 'activities[]' value = '" . $row['Activity_ID'] . "'>"; } else { echo "<input type = 'checkbox' name = 'activities[]' value = '" . $row['Activity_ID'] . "', checked>"; } echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo "<font size = '2'>" . $row['Activity_Description'] . "</font>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo "<strong><font size = '2'>Dates / times: </strong>" . $row['Activity_Date'] . "</font>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "<table border = '0' width = '541' bgcolor = 'white'>"; echo "<tr>"; echo "<td align = 'left'>"; echo "<strong><font size = '2'>Staff involved: </strong>" . $row['Activity_Staff'] . "</font>"; echo "</td>"; echo "<td align = 'right'>"; echo "<strong><font size = '2'>Location: </strong>" . $row['Activity_Location'] . "</font>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } PHP: At the moment only the first activity is printed out. This code did work before I included the second query which searches the `ifile_ActivityStudent` table. Any help with this problem would be greatly appreciated. Regards.
It looks like you are overlaying your query results. Also, take a look at using Heredoc for embedding your html code. It will make it easier to read. echo <<<HTML your html code HTML;