Setting values in an option function and the option
Moderator: General Moderators
I don't understand what the smurf you're trying to do but a sample...with pure guesses:
Form Page
Action Page
that will give you the driver_id for the name that is selected on the form page.
Form Page
Code: Select all
$getstuff = mysql_query("select CONCAT(driver_first_name, ' ' ,driver_last_name) AS name, driver_id FROM drivers ORDER BY driver_id ASC");
echo "<select name="di"><option value=""></option>";
while($row = mysql_fetch_assoc($getstuff)){
echo "<option value="".$rowї'driver_id']."">".$rowї'name']."</option>";
}
echo "</select>";Code: Select all
echo $_POSTї'di'];THAT WORKED PERFECTLY!!!
so I need to string the quotes to get the value to output correctly...
The book I got sux and am Trying to forget some of the things I learned backwords...
I'm making this for a friend of mine for so it needs to be real simple to use. the form is used to enter points then the tables are sorted by driver_id it will match up with the drivers record...
http://deaglex.net/nascar/driverstats
THANKS AGAIN for the 10 or 11th time.....
so I need to string the quotes to get the value to output correctly...
The book I got sux and am Trying to forget some of the things I learned backwords...
I'm making this for a friend of mine for so it needs to be real simple to use. the form is used to enter points then the tables are sorted by driver_id it will match up with the drivers record...
http://deaglex.net/nascar/driverstats
THANKS AGAIN for the 10 or 11th time.....
I"m not sure if there was a question wrapped up in there or not, but as someone posted in this thread earlier...you should probalby brush up your html.
here's a quick lesson:
any of those can be accessed on your action page with $_POST['formvarname']
the way you were doing it before "<select name="di[]">" creates an array for the select element named di. the only time you'd use that is if you had more than one element with the same name on the page...I personally have never seen it done with a select, but that doesn't mean it can't be...usually arrays are used with checkboxes so you can have more than one value passed to the action page with the same form var name...for your purposes, don't worry about it, just don't put [] after your var name cause that'll only smurf you up.
hope this helps some...
Burr
here's a quick lesson:
Code: Select all
<form> <!-- start of your form tag -->
<select name="joe"> <!-- an input type for your form element -->
<option value="1">bob</option> <!-- value is what gets sent to the action page stuff between the > and < is what shows up in your dropdown box -->
</select> <!-- end of your select element -->
<input type="text" name="bill"> <!-- simple text box -->
<input type="checkbox" name="kyle"> <!-- check box (on or off) -->
<input type="radio" name="billy" value="1"><!-- first radio -->
<input type="radio" name="billy" value="2"><!-- second radio for billy element -->
<textarea name="smith"></textarea> <!-- text area (larger text box) -->
</form> <!-- end form element -->the way you were doing it before "<select name="di[]">" creates an array for the select element named di. the only time you'd use that is if you had more than one element with the same name on the page...I personally have never seen it done with a select, but that doesn't mean it can't be...usually arrays are used with checkboxes so you can have more than one value passed to the action page with the same form var name...for your purposes, don't worry about it, just don't put [] after your var name cause that'll only smurf you up.
hope this helps some...
Burr