I want to build a simple search system.
I have this one page call search.php which I had a multiple select box that i retrieve from the database..

some of the code are like this:

<form method="post" action="modulartabulated.php">
  <table width="75%" border="0" align="center">
    <tr>
      <td>Date:</td>
      <td><input type="text" name="date" /></td>
    </tr>
    <tr>
      <td>Examiner:</td>
      <td><input type="text" name="examiner"  />      </td>
    </tr>
    <tr>
      <td>Program:</td>
      <td><select name="program" id="prog">
        <?
			$db=mysql_connect($hostname,$username,$password);
			mysql_select_db($dbname,$db);
			
			$query = "SELECT * from execdipprog";
			$record = mysql_query($query);
			$numrows = mysql_num_rows($record);
			
			if($numrows > 0 )
			{
				while($row = mysql_fetch_array($record))
				{
					$prog_id = $row['K_Name'];
					$prog_name = $row['K_Desc'];
					echo("<option value='$prog_name'>".$prog_name."</option>");
				}
			}
		?>
      </select></td>
    </tr>
    <tr>
      <td>Class</td>
      <td><select name="class" id="kelas">
          <?
			$db=mysql_connect($hostname,$username,$password);
			mysql_select_db($dbname,$db);
			
			$query = "SELECT * from execdipclass";
			$record = mysql_query($query);
			$numrows = mysql_num_rows($record);
			
			if($numrows > 0)
			{
				while($row = mysql_fetch_array($record))
				{
					$class_id = $row['C_Id'];
					$class_name = $row['C_Name'];
					echo("<option value='$class_name'>".$class_name."</option>");
				}
			}
		?>
        </select></td>
    </tr>
    <tr>
      <td>Module:</td>
      <td><select name="subject" id="subjek">
        <?
			$db=mysql_connect($hostname,$username,$password);
			mysql_select_db($dbname,$db);
			
			$query = "SELECT * from modul";
			$record = mysql_query($query);
			$numrows = mysql_num_rows($record);
			
			if($numrows>0)
			{
				while($row = mysql_fetch_array($record))
				{
					$sub_id = $row['M_ID'];
					$sub_name = $row['M_Desc'];
					echo("<option value='$sub_name'>".$sub_id."</option>");
				}
			}
		?>
      </select></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">
        <input type="submit" name="generate" value="Display" />
      </div></td>
    </tr>
   
  </table>
</form>

On the next page..I want to retrieve data from database according to the selected data from search.php. Can anyone tell me how to code it? I've use the regular POST method but it didn't work

Please Help

why not to store your search results on sessions....

You can grab the values from the global $_REQUEST array or $_POST array. The selected values are avaialble in the variable which has the same name as the form tag. e.g. the selected value for subject can be retrieved as $_REQUEST

use the $_POST data to do it. not $_REQUEST, in which is not very secure.

thank you for all the reply.
however i ad somethign else to my code.
I add onChange statement at the dropdown menu.

so code become like this,

<form name="modulartabulate" method="post" action="modulartabulated.php">
  <table width="75%" border="0" align="center">
    <tr>
      <td>Date:</td>
      <td><input type="text" name="date" /></td>
    </tr>
    <tr>
      <td>Examiner:</td>
      <td><input type="text" name="examiner"  />      </td>
    </tr>
    <tr>
      <td>Program:</td>
      <td><select oncahnge="modulartabulted.submit()" name="program" id="prog">
        <?
			$db=mysql_connect($hostname,$username,$password);
			mysql_select_db($dbname,$db);
			
			$query = "SELECT * from execdipprog";
			$record = mysql_query($query);
			$numrows = mysql_num_rows($record);
			
			if($numrows > 0 )
			{
				while($row = mysql_fetch_array($record))
				{
					$prog_id = $row['K_Name'];
					$prog_name = $row['K_Desc'];
					echo("<option value='$prog_name'>".$prog_name."</option>");
				}
			}
		?>
      </select></td>
    </tr>
    <tr>
      <td>Class</td>
      <td><select modulartabulted.submit() name="class" id="kelas">
          <?
			$db=mysql_connect($hostname,$username,$password);
			mysql_select_db($dbname,$db);
			
			$query = "SELECT * from execdipclass where K_Name='program'";
			$record = mysql_query($query);
			$numrows = mysql_num_rows($record);
			
			if($numrows > 0)
			{
				while($row = mysql_fetch_array($record))
				{
					$class_id = $row['C_Id'];
					$class_name = $row['C_Name'];
					echo("<option value='$class_name'>".$class_name."</option>");
				}
			}
		?>
        </select></td>

My problem is, I want the 2nd select option (drop down menu) to list the data from database according to the 1st select option (drop down menu). Using the coding above, after I selected the 1st select option (drop down menu), it redirect to the "modulartabulted.php" which suppose to happend after I click the submit button after I finish select from all the drop down list menu.

to clear it all out I'll show from example

according to the image that i've attach, i want to list out data from the database. Here a the step by step.
1. First I select Program (A)
2. Then Class (B) will list its data according to Program (A)
3. After I select Class (B), Student Name (C) will list it data according to the Class (B) that I choose.
4. Module (D) will list its data according to the Program (A) that I choose earlier.
5. After finish selecting, I click display button and it will be directed to "modulartabulated.php" page where all the date been sort according to the data I selected in previous page.

All of above happen to be in the same form.

Please help.
Thank you in advanced.

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.