mysql - PHP dynamic list pick values in next page -


am trying insert values php generated option list mysql database. error getting in "notice error". error reads:

notice: undefined index: fixture_id in c:\xampp\htdocs\project\insert.php on line 177

notice: undefined index: goalkeeper in c:\xampp\htdocs\project\insert.php on line 178

notice: undefined index: defender in c:\xampp\htdocs\project\insert.php on line 179

notice: undefined index: fullback in c:\xampp\htdocs\project\insert.php on line 180

notice: undefined index: midfielder in c:\xampp\htdocs\project\insert.php on line 181

notice: undefined index: wing in c:\xampp\htdocs\project\insert.php on line 182

notice: undefined index: striker in c:\xampp\htdocs\project\insert.php on line 183

my code given below. intermediate developer , developing team management system.

 elseif(isset($_get['selection_id'])){ // check if form submitted    echo "<table><form name=\"insertselectionform\" action=\"". $_server['php_self']."\" method=\"post\">";     echo"<tr bgcolor=\"#ccc\"><td colspan=\"2\">add selection</td></tr>";     echo"<tr><td>fixture id</td><td><select name=\"fixtures[]\">";      $sql = "select fixture_id `fixtures` ";     $data = mysql_query($sql);             while($rows = mysql_fetch_array($data)){                 echo "<option name=\"fixture_id\" value={$rows['fixture_id']} >";                 echo $rows['fixture_id'];                 echo "</option>\n";             }      echo "</select>\n";     echo "</td></tr>";     echo"<tr><td>goalkeeper</td><td><select>";     $sql = "select name `player` ";     $data = mysql_query($sql);             while($rows = mysql_fetch_array($data)){                 echo "<option name=\"goalkeeper\" value={$rows['name']}>";                 echo $rows['name'];                 echo "</option>";             }      echo "</select>";     echo "</td></tr>";     echo"<tr><td>defender</td><td><select>";      $sql = "select name `player` ";     $data = mysql_query($sql);             while($rows = mysql_fetch_array($data)){                 echo "<option name=\"defender\" value={$rows['name']}>";                 echo $rows['name'];                 echo "</option>";             }      echo "</select>";     echo "</td></tr>";     echo "<tr><td>fullback</td><td><select>";      $sql = "select name `player` ";     $data = mysql_query($sql);             while($rows = mysql_fetch_array($data)){                 echo "<option name=\"fullback\" value={$rows['name']}>";                 echo $rows['name'];                 echo "</option>";             }      echo "</select>";     echo "</td></tr>";     echo"<tr><td>midfielder</td><td><select>";      $sql = "select name `player` ";     $data = mysql_query($sql);             while($rows = mysql_fetch_array($data)){                 echo "<option name=\"midfielder\" value={$rows['name']}>";                 echo $rows['name'];                 echo "</option>";             }      echo "</select>";     echo "</td></tr>";     echo"<tr><td>wing</td><td><select>";      $sql = "select name `player` ";     $data = mysql_query($sql);             while($rows = mysql_fetch_array($data)){                 echo "<option name=\"wing\" value={$rows['name']}>";                 echo $rows['name'];                 echo "</option>";             }      echo "</select>";     echo "</td></tr>";     echo"<tr><td>striker</td><td><select>";       $sql = "select name `player` ";     $data = mysql_query($sql);             while($rows = mysql_fetch_array($data)){                 echo "<option name=\"striker\" value={$rows['name']}>";                 echo $rows['name'];                 echo "</option>";             }      echo "</select>";     echo "</td></tr>";     echo"<tr><td></td><td><input type=\"submit\" value=\"add selection\" name=\"selection\"></td></tr>";     echo "</table></form>"; }   elseif(isset($_post['selection'])){             //collect variables posted form.             $fixture_id = mysql_real_escape_string($_post['fixture_id']);             $goalkeeper = mysql_real_escape_string($_post['goalkeeper']);             $defender = mysql_real_escape_string($_post['defender']);             $fullback = mysql_real_escape_string($_post['fullback']);             $midfielder = mysql_real_escape_string($_post['midfielder']);             $wing = mysql_real_escape_string($_post['wing']);             $striker = mysql_real_escape_string($_post['striker']);              $sql = "select * fixtures fixture_id = '$fixture_id'";             $data = mysql_query($sql);             while($rows = mysql_fetch_array($data)){             $opponents = $rows['opponents'];             }        //validate form checking empty strings user might have submitted using strlen() php built-in method. if no empty string form processes          if(strlen($fixture_id)>0 && strlen($goalkeeper)>0 && strlen($defender)>0 && strlen($fullback)>0 && strlen($midfielder)>0 && strlen($wing)>0 && strlen($striker)>0 ){ // if form fields not empty, insert in database                 $sql = "insert `selections` (fixture_id, opponents, goalkeeper,defender,fullback,midfielder,wing,striker) values('$fixture_id','$opponents', '$goalkeeper','$defender','$fullback','$midfielder','$wing','$striker')";                 $query = mysql_query($sql) or die("error. ". mysql_error()) ;                 echo "selection added <br/><br/>";                 echo " <a href=\"team_selections.php\">go team selections page </a>";             }          } 

you have wrongly interpreted name attribute in <select>. have give name attributes like

<select name=\"fixture_id\"> , not in <option name="fixture_id">

so remove name attribute <option> (remove <option>) , specify in <select>


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -