Show related information on the same page (underneath) after selecting a row from an html form

I’m trying to do the following and wonder if somebody could possibly help?

I’m populating a form with several rows of values populated out of an MySQL DB, as follows:

<?php
	  echo '<FORM ACTION="GoAndDoThis.php" METHOD="POST">';
	  echo '<SELECT SIZE=18 WIDTH=50 MULTIPLE NAME="pd">';
	  while ($row = mysqli_fetch_array($sql_result, MYSQLI_NUM))
		{	
		  echo '<OPTION VALUE='.$row[0].'>'.$row[0].' - '.$row[1];
		}
	  echo '</SELECT>';
	  echo '<BR><BR>';
	  echo '<INPUT TYPE="SUBMIT" VALUE="Select Row">';
	  echo chr(32).'<b>... click to see more information</b>';
	  echo '</FORM>';
?>

… when I select a row and hit the submit value, the php routine “GoAndDoThis.php” is called/executed but the information I need (just grid of related data) appears on a new page.

I would like this information to appear directly underneath the form instead of going off to a new page.

I think it may involve JavaScript but not sure.

Appreciate some help with this if at all possible.

What you are referring too is called Ajax functionality.

However, you will need a page that handles requests and gets the data you are after as well. (You can do it in the same file if you do it correctly, but it is easier to have a separate page when you first start out.

Sounds like he just wants a single page form which would not require Ajax.

OP, normally you would have your php at the top of the page and html below it. Since you want the form data to show below the form just switch it around. HTML at the top, PHP output at the bottom. Also, remove the form action completely to submit to the same page. This is a very simple process.

Sponsor our Newsletter | Privacy Policy | Terms of Service