I\'ve been working on something for the past few days but this one bit of code perpetually throws an unexpected T_ECHO. My friends can\'t seem to find anything wrong with it an
You could use short tags to make this far more readable and likely less error prone.
<?php while ($row = mysql_fetch_array($result, MYSQL_ASSOC)): ?>
<tr>
<td><?= $row["site_description"] ?></td>
<td><?= $row["url"] ?></td>
<td>
<select>
<?php while ($roar = mysql_fetch_array($categories, MYSQL_ASSOC)): ?>
<option><?= $roar["category"] ?></option>
<?php endwhile; ?>
</select>
</td>
</tr>
<?php endwhile; ?>
Try this...
I think it may have been falling over because once you've parsed the categories resultset, for the first site, it comes up with nothing the next time you call mysql_fetch_array. So, doing this upfront and popping the results into a variable fixes that.
I've added "\t" and "\n" to the strings to make the html format prettily in view source.
$result = mysql_query("select * from tmp_sites");
$categories = mysql_query("select * from tmp_cats");
$select_options = "";
while ($roar = mysql_fetch_array($categories, MYSQL_ASSOC)):
$select_options .= "\t\t<option value=\"". $roar["category"] ."\">". $roar["category"] ."</option>\n";
endwhile;
echo "<table>";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)):
echo "\t<tr>\n";
echo "\t\t<td>". $row["site_description"] ."</td>\n";
echo "\t\t<td>". $row["url"] ."</td>\n";
echo "\t\t<td><select>\n";
echo $select_options;
echo "\t\t</select></td>\n";
echo "\t</tr>\n";
endwhile;
echo "</table>"