Page 2 of 2

Posted: Thu Feb 24, 2005 9:52 pm
by feyd
why does the option have a name? shouldn't that be value?

Posted: Thu Feb 24, 2005 9:59 pm
by Burrito
I don't understand what the smurf you're trying to do but a sample...with pure guesses:

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))&#123;
echo "<option value="".$row&#1111;'driver_id']."">".$row&#1111;'name']."</option>";
&#125;
echo "</select>";
Action Page

Code: Select all

echo $_POST&#1111;'di'];
that will give you the driver_id for the name that is selected on the form page.

Posted: Thu Feb 24, 2005 10:19 pm
by Deaglex
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.....

Posted: Thu Feb 24, 2005 11:17 pm
by Burrito
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:

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 -->
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