GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 19-Oct-2006, 11:01
shams shams is offline
New Member
 
Join Date: Dec 2004
Posts: 12
shams is on a distinguished road
Exclamation

how to pass the value of selected drop-down menu in variable to another page?


hi,
there is a php-myql script that list the mysql databases in the drop-down menu, i want the selected database from the drope down menu should pass in the $db_name to the test php, the script list the databases in the drop-down menu ok, now this is the test.php:

PHP Code:

<?php
echo 'hello'.$db_name;
?>


the $db_name should be the selected database, but the output of test.php is:
hello Db_list
this is the listDb.php:

PHP Code:

<html>
<head><title>List DB</title></head>
<body>
<form method="POST" action="test.php"><div align="center"><center><p>Select Db
<input type="hidden" name="db_name" value="Db_list">
<SELECT NAME="Db_list">
<?php
$link = mysql_connect('localhost', 'user', 'pass') or die(mysql_error());
$db_list = mysql_list_dbs($link);

while ($row = mysql_fetch_object($db_list)) {
echo "<option value=\"$row->Database\">$row->Database</option>";
}
?>
</select>
<input type="submit" value="Submit"></center></div>
</form>
</body>
</html> 

__________________
http://www.shams.at.tt
Last edited by LuciWiz : 19-Oct-2006 at 16:08. Reason: Please insert your Php code between [php] & [/php] tags
  #2  
Old 19-Oct-2006, 16:24
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 841
admin will become famous soon enough

Re: how to pass the value of selected drop-down menu in variable to another page?


Because you named the SELECT element as Db_list, the script (test.php) should be re-written so:

PHP Code:

<?php
echo 'hello ' . $_POST['Db_list']; // NOT $db_name
?>


You already have a hidden input element named db_name before the select.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #3  
Old 19-Oct-2006, 19:45
shams shams is offline
New Member
 
Join Date: Dec 2004
Posts: 12
shams is on a distinguished road

Re: how to pass the value of selected drop-down menu in variable to another page?


thanks admin, that works great now.
__________________
http://www.shams.at.tt
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shapes Functions Version 2 - Arrays! Cecil C Programming Language 1 09-Jul-2006 21:39
Pass by references? Cecil C Programming Language 4 29-Jun-2006 03:30
Need Help Modifiying the script of a menu demtro Web Design Forum 1 23-Sep-2005 20:30
How do I install a drop down menu? rhino1616 Web Design Forum 1 30-Aug-2005 06:22
Can someone suggestion a nice drop down menu? rhino1616 Web Design Forum 4 22-Aug-2005 11:16

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 10:37.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.