doddsey_65 Posted November 23, 2010 Share Posted November 23, 2010 i am trying to create a combo box so the user can order topics by asc or desc. The problem is trying to get the name of the option to Ascending or Descending and the value to asc or desc. Heres what i have so far: $order_name = array('Ascending', 'Descending'); $order_value = array('asc' => 'Ascending', 'desc' => 'Descending'); echo "<div style=\"float:right;\">"; echo "<form name=\"order_form\" action=\"{$site_root}/index.php\" method=\"GET\">"; echo "<input type=\"hidden\" value=\"{$forum_id}\" name=\"forum\" />"; echo "<select name=\"order_by\" style=\"margin-left:5px;\">"; foreach ($order_name as $i) { echo "<option name=\"order_by_option\" value=\"{$order_value}\"/>"; echo "Order By: {$i}"; echo "</option>"; } echo "</select>"; when i try to order them the GET value is Array. Any ideas? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted November 23, 2010 Share Posted November 23, 2010 Not enough info. what GET value? can we see the form processing code? what does the form HTML look like when you View Source? Quote Link to comment Share on other sites More sharing options...
doddsey_65 Posted November 23, 2010 Author Share Posted November 23, 2010 ok here is the form html when viewing source: <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 By: Ascending </option> <option name="order_by_option" value="Array"/> Order By: Descending </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>"; } the order by is fine, it lists the options Ascending and Descending. but it doesnt give them the proper values (asc, desc). instead it just assigns the value array. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted November 23, 2010 Share Posted November 23, 2010 you set $order_value as an array, then you assign the value of the form as $order_value. thus, the value of the form is an array. you might want to loop over that array, creating an option for each value. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.