SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Jan 7, 2005, 07:48 #1
- Join Date
- Nov 2003
- Location
- Norwich UK
- Posts
- 134
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Building a select statement but...
the required values are not appearing in a select drop down
code
PHP Code:<td width="56%"><form name="form3" method="post" action="">
<?php
for($i = $std; $i <= $dmth; $i++){
$opts = array($i);
$value = $i;
$name = $i;//print_r($i);
}
echo "<select name='select3'>";
foreach($opts as $opt){
$selected = "SELECTED";
}
echo "<option value='" .$opt["value"] . "' $selected>";
echo $opt["name"];
echo "</option>";
echo "</select>";?>
</form></td>
-
Jan 7, 2005, 07:53 #2
- Join Date
- Dec 2004
- Location
- Bristol, UK
- Posts
- 259
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Whoa, quite a few mistakes there - look at the following code which will do what you want and then ask if you have any questions about it. Might be easier than debugging what you posted
PHP Code:<form>
<select name="select3">
<?php
$start = 1;
$end = 20;
for ($i = $start; $i <= $end; $i++)
{
echo "<option>$i</option>";
}
?>
</select>
</form>
Rich
Bookmarks