Page 1 of 1

where is the cahe needed...?

Posted: Mon Oct 03, 2005 12:35 am
by rami
i have a combo box which dispalys batch entered in the table batch_id
batch(batch_id,program)
combo2.php

Code: Select all

<form action="combo1.php" method="post"> 
<select name="uid1"><option >select one</option>
<?php
require_once ('../mysql_connect1.php');
$query = "SELECT batch_id,program  from batch";		
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
	echo '<option value="'.$row['batch_id'].'">'.$row['program'].'</option>';
}
mysql_close();
?>
</select>
<input type="submit" value="Show Data!"> 
</form>
in combo1.php i want to display name from students table according to batch clilked in combo2.php

student table has user_id,name,batch_id....

combo1.php

Code: Select all

<form action="disstudents.php" method="get"> 
<select name="uid"><option >select one</option>
<?php
require_once ('../mysql_connect1.php');
$query = "SELECT * FROM students WHERE user_id =". $_GET['uid1']."";
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
	echo '<option value="'.$row['user_id'].'">'.$row['name'].'</option>';
}
mysql_close();
?>
</select>
<input type="submit" value="Show Data!"> 
</form>
but its not working as it should
how can i get desired result
any help
(core:combo to combo data pass)
thanks for help

Posted: Mon Oct 03, 2005 12:42 am
by ruchit
use 2 forms... place your first combo in first form... submit this form thru javascript on onChange event of the first combo.....
then you'll be able to use your same (2nd combo) code in the 2nd form... just check to see

Code: Select all

if (isset($_GET['combo1'])){
  //output 2nd form
}

Posted: Mon Oct 03, 2005 12:58 am
by rami
ruchit wrote:use 2 forms... place your first combo in first form... submit this form thru javascript on onChange event of the first combo.....
then you'll be able to use your same (2nd combo) code in the 2nd form... just check to see

Code: Select all

if (isset($_GET['combo1'])){
  //output 2nd form
}
if i used have script i can do it but i need as many page as there option in first combo box so not quite good.....

so isn't there better way
why isn't this code working

Code: Select all

$query = "SELECT * FROM students WHERE user_id =". $_GET['uid1']."";
the combo 2 is passing value as well...
so may be if we can make this run will be very good

other wise i must just javascript
and use drop down menu of javascript to open separete page for each option in combo2....(first combo)

any better idea or example
thanks for answer

Posted: Mon Oct 03, 2005 1:43 am
by ruchit
f i used have script i can do it but i need as many page as there option in first combo box so not quite good.....
you are wrong... you don't need as many pages as there are options... it would work fine for your existing script... can u pls post the code u have after having 2 forms on the page