I have a dropdown box that is dynamically populated from the db, it works perfectly until I place it into a variable i.e. $block
once placed inside the variable it fails to draw anything from the db.
Code:
$block = "
<form name=\"form1\" method=\"post\" action=\"InsertEmp2.php\">
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td>Select the leader</td>
<td>
<select name=\"leader\">
<option value=\"\">Choose a Team Leader...</option>
$SQL = \"SELECT * FROM staff_table INNER JOIN leader ON leader.staff_id=staff_table.staff_id\";
$MySQLQuery = mysql_query($SQL)
or die(mysql_error());
// loop thru the results
// print each result to a select option
while ($leaderdd = mysql_fetch_row($MySQLQuery)) {
print \"<option value=\"$leaderdd[9]\">$leaderdd[1]</option>\n\";
}
</select></td>
</tr>
</table>
</form>
";
Can anyone explain this to me please. Why does it fail to work once inside the variable.
This code is used to display $block
<?
if ($position < "4") {
echo $block;
}
Any help would be great thanks.
Matt Thornhill