| | |
[HELP] Regarding on select Box
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
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:
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
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:
PHP Syntax (Toggle Plain Text)
<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
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['subject']
Stuck in the middle of Java/PHP/Ajax development?
For free help on any technology and free articles visit http://www.techcubetalk.com
For free help on any technology and free articles visit http://www.techcubetalk.com
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
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,
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.
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.
Last edited by syazuchan; Jan 4th, 2009 at 10:20 pm.
![]() |
Similar Threads
- passing values of Select box from JSP to Action class thru form Bean (JSP)
- Select box that changes textbox value (JavaScript / DHTML / AJAX)
- Populating Select Box w/ Passed In Value? (JavaScript / DHTML / AJAX)
- onClick html select box help, passing selected value and populating select box (JavaScript / DHTML / AJAX)
- Select Box populates text field (JavaScript / DHTML / AJAX)
- bringing data from mysql using select box (PHP)
- populate a select box using PHP (PHP)
Other Threads in the PHP Forum
- Previous Thread: Multilanguage with PHP-MySQL
- Next Thread: what is php stands for
| Thread Tools | Search this Thread |
.htaccess alerts apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database date display duplicates dynamic echo email emptydisplayvalue error errors explodefunction file files folder form forms function functions google hack href htaccess html htmlspecialchars image include insert ip javasciptvalidation javascript joomla keywords limit link login loop mail menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect regex remote script search securephp server sessions shot sms soap source space sql subscription syntax system table tutorial update upload url validator variable video web xml youtube






