where is the cahe needed...?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rami
Forum Contributor
Posts: 217
Joined: Thu Sep 15, 2005 8:55 am

where is the cahe needed...?

Post 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
ruchit
Forum Commoner
Posts: 53
Joined: Mon Sep 26, 2005 6:03 am

Post 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
}
rami
Forum Contributor
Posts: 217
Joined: Thu Sep 15, 2005 8:55 am

Post 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
ruchit
Forum Commoner
Posts: 53
Joined: Mon Sep 26, 2005 6:03 am

Post 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
Post Reply