aggiefan
07-20-2006, 06:58 AM
I have the following code in my php file. The code creates a dropdown in my template of all the teams in the vbcontest_teams_ncaafootball database. I want it to capture the selected team and write it to a different table in the database. If I include the write to db part inside the while loop -- it writes all 12 options (so you can't tell what was selected. If you put it outside of the while loop, it writes a blank. Any ideas on what needs to be there to capture the selected value in the dropdown? See the screenshot if it helps you visualize it.
if ($_GET['action'] == "createweek") {
$query_teams=$vbulletin->db->query('select team_name from ' . TABLE_PREFIX . 'vbcontest_teams_ncaafootball');
$teams='';
while($tea=$vbulletin->db->fetch_array($query_teams)){
$selected='';
if(@$_REQUEST['team_name']==$tea['team_name'])
$selected=' selected';
$teams.="<option value=\\\"".$tea['team_name']."\\\"$selected>".$tea['team_name']."</option>";
$errormessage = "<center>Congratulations! You have successfully created your contest. You can now advance to creating weeks. Click below to begin or use the navigation in the adminCP.<br><br><a href=/forums/admincp/contestv2admin2.php?action=createweek>Click here to continue on and create a week for your contest</a href>";
$answerall = true;
}
if ($_POST['action'] == "submit") {
if ($num == '5)
{
$errormessage = "$vbulletin->userinfo[username], you have 5 contests in the database already. Please delete one before continuing. Maintaining your contests will provide for quicker queries and better results for your users.";
eval('print_output("' . fetch_template('STANDARD_ERROR') . '");');
exit();
}
eval('$formsend = "' . fetch_template('vBContestanswers') . '";');
$db->query_write("INSERT INTO " . TABLE_PREFIX . "vbcontest_teams_ncaafootball (`team_name`) VALUES ('\\\"".$tea['team_name']."\\\"$selected' (https://vborg.vbsupport.ru/))");
}
if ($_GET['action'] == "createweek") {
$query_teams=$vbulletin->db->query('select team_name from ' . TABLE_PREFIX . 'vbcontest_teams_ncaafootball');
$teams='';
while($tea=$vbulletin->db->fetch_array($query_teams)){
$selected='';
if(@$_REQUEST['team_name']==$tea['team_name'])
$selected=' selected';
$teams.="<option value=\\\"".$tea['team_name']."\\\"$selected>".$tea['team_name']."</option>";
$errormessage = "<center>Congratulations! You have successfully created your contest. You can now advance to creating weeks. Click below to begin or use the navigation in the adminCP.<br><br><a href=/forums/admincp/contestv2admin2.php?action=createweek>Click here to continue on and create a week for your contest</a href>";
$answerall = true;
}
if ($_POST['action'] == "submit") {
if ($num == '5)
{
$errormessage = "$vbulletin->userinfo[username], you have 5 contests in the database already. Please delete one before continuing. Maintaining your contests will provide for quicker queries and better results for your users.";
eval('print_output("' . fetch_template('STANDARD_ERROR') . '");');
exit();
}
eval('$formsend = "' . fetch_template('vBContestanswers') . '";');
$db->query_write("INSERT INTO " . TABLE_PREFIX . "vbcontest_teams_ncaafootball (`team_name`) VALUES ('\\\"".$tea['team_name']."\\\"$selected' (https://vborg.vbsupport.ru/))");
}