Jump to content

[SOLVED] place loop inside a select form field?


jarv

Recommended Posts

At the moment my code outputs many select boxes with all dates, I want one select box with all the dates, how can i do this?

$result3 = mysql_query("SELECT HeaderDate FROM Headertbl");


while($row2 = mysql_fetch_array($result3))
      {
      $HeaderDate = $row2['HeaderDate'];
echo '<h2><select name="$HeaderDate"><option value="'.$HeaderDate.'">'.$HeaderDate.'</option></select></h2>';
}

I think you mean this:

$result3 = mysql_query("SELECT HeaderDate FROM Headertbl");
print '<h2><select name="$HeaderDate">';
while($row2 = mysql_fetch_array($result3))
      {
echo "<ption value=\"{$row2['HeaderDate']}\">{$row2['HeaderDate']}</option>';
}
print '</select>';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.