combo box to page

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

combo box to page

Post by rami »

i have combobox as follows

Code: Select all

<form action="disstudents.php" method="POST"> 
<select name="user_id"><option >select one</option>
<?php
require_once ('../mysql_connect1.php');
$query = "SELECT user_id,name  from students";		
$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>
i have disstudents.php which displays students in database as uid passes ie
localhost/disstudnets.php?uid=10;
with link that page is working fine
but what i want to do is from that combo box pass that uid to disstudents.php but it is not working
how can i do it
i want to open page(disstudents.php) taking uid from combo box which displays studnets name..

now it says missiong uid ..in disstudents.php

any help
thanks...
rami
ruchit
Forum Commoner
Posts: 53
Joined: Mon Sep 26, 2005 6:03 am

Post by ruchit »

replacing this

Code: Select all

<form action="disstudents.php" method="POST">
with

Code: Select all

<form action="disstudents.php" method="GET">
would do it for you
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Or even better solution, use $_POST['uid'] instead of $_GET['uid'] on the receiving page :)

(or use $_REQUEST which does both - and cookies aswell, but that is semi-irrelevant for now)
rami
Forum Contributor
Posts: 217
Joined: Thu Sep 15, 2005 8:55 am

Post by rami »

Jenk wrote:Or even better solution, use $_POST['uid'] instead of $_GET['uid'] on the receiving page :)

(or use $_REQUEST which does both - and cookies aswell, but that is semi-irrelevant for now)
Thanks my RUCHIT
i must have given second thought in it....

but mr jenk answer is not quite clear to me....

Mr ruchit ...
i have been searching for this code from quite some time now may be you can help me i feel so.
may be you can give me 5 minutes...

i have table batch(batch_id,program)
i made combo box as
batch
science2000
science2001
science2002

i have another one table students...
students(user_id,name,batch_id,program,address)

what is want is went some body clicks at a option on the first combo ie batch ...
the next page should dispaly combo box with students name in that batch(only)

(next i can do myself
displaying data about selected students from above answers and code)

my problem is sending id from one combo box to another combo....

i feel that it can be made by modifying some parts from above codes so please copy it paste it and make changes...

may be 5 minutes....

really thanks for help
any body can do ...
i have been looking for it from quite some time now
so any help
thanks
Post Reply