...

View Full Version : <SELECT> Help needed



rmdort
09-11-2005, 05:10 PM
I am having a registration page here

http://ntudebatingsociety.org/iv/register.php

When a user select the No of teams, i use a for statement to display one table each for a team in the next page register2.php
Quote:
for ($i=1;$i<=$teams;$i++)
{
print'<p class=\"text\">Team&nbsp;&nbsp;';echo"$i";print'</p><table border=1 class=\"tablestructure\">
<tr><td class=\"listtable\">Team Number</td><td><select name='.$teamselect.'[i]><option value=1>A</option>
<option value=1>A</option>
<option value=2>B</option>
<option value=3>C</option>
<option value=4>D</option>
<option value=5>E</option>
<option value=6>F</option>
<option value=7>G</option>
<option value=8>H</option>
<option value=9>I</option>
<option value=10>K</option>
</select></td></tr>
<tr><td class=\"listtable\">Member 1 Name</td><td><input type=text name=\"member1name\"></input></td></tr>
<tr><td class=\"listtable\">Accommodation</td><td><select name=accomselect[]><option value=1>Dormitory</option><option value=2>Other</option></select></td></tr>
<tr><td class=\"listtable\">Details</td><td><textarea name=detail[] cols=30 rows=5></textarea></td></tr>
<tr><td></td></tr>
<tr><td class=\"listtable\">Member 2 Name</td><td><input type=text name=\"member1name\"></input></td></tr>
<tr><td class=\"listtable\">Accommodation</td><td><select name=accomselect[]><option value=1>Dormitory</option><option value=2>Other</option></select></td></tr>
<tr><td class=\"listtable\">Details</td><td><textarea name=detail[] cols=30 rows=5></textarea></td></tr>
</table><br>';

}


After he clicks submit, i execute the page finish.php and i need all the selected Team Numbers[eg A,B,C etc] of all the teams as an array or something so that i can mail the details.

Is there any way to do this.. Can i pass the <select name= to an array> so that i can retrieve them in the next page using $_REQUEST['array'] ????

any help would be appreciated.

raf
09-11-2005, 06:58 PM
welcome here!

first off --> take a look at your current code:
- if you print singlequoted-strings, then you don't need to escape double quotes
- does $teamselect has a value? and was [i] meant to be a literal?
- for your code, you'd better replace the print by an echo with multiple arguments.

about your question: your not really clear on what you want. getting the team numbers as an array or something, so you can mail it kinda vague. do you also need the related data (like accomodation, details etc)?

Assuming you only need the selected teams --> you could make an array of your hltm-field by using formfieldnames like


echo '<select name="teamdetails[teamnumber][', $i ,']" ...> ... </select>';


and you can then implode the selected values like this

$arr_selected_teamnumbers = array_values($_POST['teamdetails['teamnumber']']));

wich will get you an array of the selected teams.

rmdort
09-11-2005, 07:06 PM
..resolved....

I set the teamarray to

$teamarray = array(A, B, C, D, E, F,G, H, I, J, K);

i called the select

echo'</p><table border=1 class=\"tablestructure\">
<tr><td class=\"listtable\">Team Number</td><td><select name=';echo $teamarray[$i];echo'><option ...

next page
$teamarray = array(A, B, C, D, E, F,G, H, I, J, K);
and called all values using
$HTTP_POST_VARS[$teamarray[$i]];

a bit like u r code.. thanks for the info raf..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum