An7hony Posted March 30, 2011 Share Posted March 30, 2011 I'm having the strangest thing happing. When posting a form i'm not getting the option value. Instead its posting my text field ie: <option name="1">text</option> <?php $query = "SELECT id, name FROM locations ORDER BY name"; $res = mysql_query($query, $cid); while($a = mysql_fetch_array($res)) { echo "<option name=".$a["id"].">".$a["name"]."</option>"; } ?> <?php The code thats grapping it: if($_POST['location']==""){ $location = ""; echo '<div class="message error">Please enter a <strong>Location</strong></div>'; }else{ $location = $_POST['location']; } ?> Can anyone see why? I have also tried it in html to see if its my php, but i get the same result Quote Link to comment https://forums.phpfreaks.com/topic/232182-option-value/ Share on other sites More sharing options...
adamlacombe Posted March 30, 2011 Share Posted March 30, 2011 From what I see I think name= needs to be value= Quote Link to comment https://forums.phpfreaks.com/topic/232182-option-value/#findComment-1194376 Share on other sites More sharing options...
An7hony Posted March 30, 2011 Author Share Posted March 30, 2011 thank you!! what a stupid mistake, now i feel silly Quote Link to comment https://forums.phpfreaks.com/topic/232182-option-value/#findComment-1194383 Share on other sites More sharing options...
adamlacombe Posted March 30, 2011 Share Posted March 30, 2011 lol its okay, I feel pretty stupid myself with the things I post on here XD Quote Link to comment https://forums.phpfreaks.com/topic/232182-option-value/#findComment-1194384 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.