I have a dynamic drop down that allows me to select an item. That item is posted to a new page that I run a query against to build/populate my form that I'm wanting to update a column in. However the issue is after I hit my submit button it no longer knows about my post variable. I get the following error.

on line 39: Undefined index: mevent

Code from drop down. This is in its own php file.

echo "<a href=''>Manage Individual Event Result</a></br>";
$quer2=mysql_query("SELECT DISTINCT event FROM er1 order by event");
// End of query for first list box

echo "<form method=post name=f2 action='mansignleeventr.php'>";
// Add your form processing page address to action in above line. Example  action=dd-check.php
//Starting of first drop downlist 
echo "<select name='mevent' onchange=\"reload(this.form)\"><option value=''>Select Event</option>";
while($noticia2 = mysql_fetch_array($quer2)) { 
if($noticia2['event']==@$cat){echo "<option selected value='$noticia2[event]'>$noticia2[event]</option>"."<BR>";}
else{echo  "<option value='$noticia2[event]'>$noticia2[event]</option>";}
}
echo "</select><input type=submit value=Submit></br>";
echo "</form>";

This is on the mansignleeventr.php page where mevent is passed to. It works on the first population but after I hit submit to update my form I get the error.

<?php
$e=$_POST['mevent']; //gives event now
//echo $e;

$query = "SELECT a.id, a.firstname, a.lastname, e.eorder, e.event, e1.result, e1.eventrank, e1.eventscore, e1.date, e1.id
			FROM
			er1 e1
			LEFT JOIN athlete a ON (e1.athlete_id = a.id)
			LEFT JOIN events e ON (e1.event = e.event)
			where e.event='$e'
			ORDER BY eventrank";
	
$res = mysql_query($query);
	if (!$res){
		die('Error with query: ' . mysql_error());
	}
$k = 1;
$bg = '#eeeeee'; 
while ($row = sqlFetchArray($res)) {
	$id[]=$row['id']; 
	//echo $row['event'];
	$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');
	  echo '<tr bgcolor="' . $bg . '">
      <td align="left">' . $row['firstname'] . '</td>
      <td align="left">' . $row['lastname'] . '</td>
      <td align="left"><input name="event[]" id="event" value="' . $row['event'] . '" /></td>
      <td align="left"><input type="text" size="10" name="result[]" id="result" value="'.$row['result'].'" /></td>
      <td align="left">' . $row['eventrank']. '</td>
      <td align="left">' . $row['eventscore']. '</td>
      <td align="left">' . $row['date'] . '</td>
      
      </tr>';
	
	$k++;
	
	
} // End of WHILE loop.
echo '</table>';
echo '<input type="submit" name="Submit" value="Submit">';
echo '</form>';


if(isset($_POST['Submit'])){//1
for($i=0;$i<$count;$i++){//2
	$r = $_POST['result'][$i];

	$e = $_POST['event'][$i];

	$sql = "UPDATE er1 set result='$r' WHERE event='$e' and id='$id[$i]'";	
	mysql_query($sql);
	$res = mysql_query($sql);
	if (!$res){//3
		die('Error with query: ' . mysql_error());
	}//3 
	
	
 //}
 }//2
}//1

where is starting of form tag in your last code?
and where is $count in line no. 28?
Post complete page and also error you are getting....

The files are attached.

display.functions.inc.php has the code for the dynamic select that sends the post data to
mansignleeventr.php. On the initial select the form is populated but after I modify results for any of the events and hit submit I get the error on Undefined index 'mevent'. The rest of the code works, if I hard code the event value it gets updated. Just doesn't work unless its hard-coded.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.