Hello Friends,

i have created a page, here a sql query retrieve students name from database and put these values in drop down options.

now i want, i select a value from drop down and send it ot another page. but it is not working. on my next page nothing received. it is showing blank.

please help to do this.



My form code is:


$result = mysql_query("SELECT * FROM 8a");

echo "<form action='marksheet.php' method='post'>";

echo "<font color='#FFFFFF'>Selece Student: <select name='st'>";

 while($row = mysql_fetch_array($result))

  echo "<option value='".$row['1']."'>".$row['1']."</option>"; 

echo "</select>";

echo "<input type='submit' value='Print Marksheet'/>";
echo "</form>";


Recommended Answers

All 2 Replies

in the marksheet.php page you can access selected student by following line of code, in the begnining of the page

echo $_POST['st'];

or you dump post array to check what is posted like

echo "<pre>";
echo "</pre>";

echo "<option value='".$row['1']."'>".$row['1']."</option>";

the array index isn't a string its a integar:

 echo "<option value='".$row[1]."'>".$row[1]."</option>";

also just in case, index starts at 0 so the first column will be $row[0]

Be a part of the DaniWeb community

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