Friday, 13 April 2012

combo box using arrays

<form name="order_form" action="http://localhost/myforum/index.php" method="GET">
<
input type="hidden" value="1" name="forum" />
<
select name="order_by" style="margin-left:5px;">
<
option name="order_by_option" value="Array"/>Order ByAscending</option>
<
option name="order_by_option" value="Array"/>Order ByDescending</option>
</
select>
<
input type="submit" value="Order" />
</
form>



Basically all i want to do is have Order By: Ascending and the relevent option value to be asc
or Order: By Descending and its option value to be desc. I thought I could use an array like:

$order_name = array('Ascending''Descending');$order_value = array('asc' => 'Ascending''desc' => 'Descending');

and then have a foreach loop to echo the options for how ever many there are in the array like so:

foreach ($order_name as $i)
 
{
 
echo 
"<option name=\"order_by_option\" value=\"{$order_value}\"/>";
 
echo 
"Order By: {$i}";
 
echo 
"</option>";
 
}

No comments:

Post a Comment