rich_traff Posted February 8, 2011 Share Posted February 8, 2011 Hi, i have written a form that uses 3 dropdown boxes, one of them being populated from a database. The form code is as follows; <form id="pointsForm" name="pointsForm" method="post" action="points-engine.php"> <select name="car" id="car"> <?php // result of car name collection $result = mysql_query ($query); //Array stored in $cars while($cars=mysql_fetch_array($result)){ //option values added by looping through array echo "<option value=$cars[id]>$cars[carName]</option>"; } ?> </select> <select name="season" id="season"> <option value="low">Low season</option> <option value="mid">Mid season</option> <option value="high">High season</option> <option value="peak">Peak season</option> </select> <select name="period" id="period"> <option value="day">One day</option> <option value="weekend">Weekend</option> <option value="week">One week</option> </select> <input type="submit" name="Submit" value="Submit" /> </form> which posts to; <?php $car=$_POST['car']; echo $car; $season=$_POST['season']; echo $season; $period=$_POST['period']; echo $period; ?> The initial form code is working fine, the car field is being populated from the database. My problem is the post value for car isn't working... points-engine.php is echoing $season & $period fine but not $car can anyone tell me why? many thanks Richard Link to comment https://forums.phpfreaks.com/topic/227098-form-using-php-is-not-posting-value/ Share on other sites More sharing options...
Pikachu2000 Posted February 8, 2011 Share Posted February 8, 2011 To be valid markup, the value= attributes should be quoted. The array indices should really also be quoted. echo "<option value=\"{$cars['id']}\">{$cars['carName']}</option>"; Link to comment https://forums.phpfreaks.com/topic/227098-form-using-php-is-not-posting-value/#findComment-1171577 Share on other sites More sharing options...
rich_traff Posted February 8, 2011 Author Share Posted February 8, 2011 Many thanks, thats done the trick! Link to comment https://forums.phpfreaks.com/topic/227098-form-using-php-is-not-posting-value/#findComment-1171584 Share on other sites More sharing options...
Pikachu2000 Posted February 8, 2011 Share Posted February 8, 2011 No problem. Please mark the thread solved, if it indeed is . . . Link to comment https://forums.phpfreaks.com/topic/227098-form-using-php-is-not-posting-value/#findComment-1171585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.