| | |
php script for dropdown to fetch DB list and then Tables
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2007
Posts: 7
Reputation:
Solved Threads: 0
Dear members, I am new for Php, wish to develope two dropdown list. One listing all DB's availabe with MySQL and on selection of one DB second should list tables in that DB ( with no 'GO' type button). Once Table selected third dropdown will list fileds availabe,
Can some one help me.
Thanks in advance.
Sunilpro
Can some one help me.
Thanks in advance.
Sunilpro
•
•
•
•
Dear members, I am new for Php, wish to develope two dropdown list. One listing all DB's availabe with MySQL and on selection of one DB second should list tables in that DB ( with no 'GO' type button). Once Table selected third dropdown will list fileds availabe,
Can some one help me.
Thanks in advance.
Sunilpro
Read carefully articles about security!
1. Access to all databases should have only root account! To make the thing you want you should log in from php as root! This is not secure at all!
2. If you want to make this, you should create a user granted view only. AND AVOID GIVING VIEW PERMISSIONS TO MYSQL_USER tables and DBS
3. The "no go" button change can be done with javascript, not with PHP. PHP can only insert the script where you need it. Look for onChange actions in some javascript reference.
If you still want to do this...well, we might guide you!
Good luck
•
•
Join Date: Feb 2007
Posts: 7
Reputation:
Solved Threads: 0
Thanks a lot
I am writing a small offline apps to convert some data of multiple tables into one table with some middle processing and changes hence no problem of EXPOSURE so please guide me further.
Basically I am also new to JS Hence cannot undersatnd how to pass to and fro from PHP& JS.
Thanks for gre8 clue for onchange() event.
The specific prbolem with me is that I am stuck with >> How to choose SELECTED value (of listed database names) and pass on to the another dropdown which list the TABLES on SELECTED DB,
Thanks
Sunipro
I am writing a small offline apps to convert some data of multiple tables into one table with some middle processing and changes hence no problem of EXPOSURE so please guide me further.
Basically I am also new to JS Hence cannot undersatnd how to pass to and fro from PHP& JS.
Thanks for gre8 clue for onchange() event.
The specific prbolem with me is that I am stuck with >> How to choose SELECTED value (of listed database names) and pass on to the another dropdown which list the TABLES on SELECTED DB,
Thanks
Sunipro
•
•
•
•
Thanks a lot![]()
I am writing a small offline apps to convert some data of multiple tables into one table with some middle processing and changes hence no problem of EXPOSURE so please guide me further.
Basically I am also new to JS Hence cannot undersatnd how to pass to and fro from PHP& JS.
Thanks for gre8 clue for onchange() event.
The specific prbolem with me is that I am stuck with >> How to choose SELECTED value (of listed database names) and pass on to the another dropdown which list the TABLES on SELECTED DB,
Thanks
Sunipro
1. in order to access the DB with full privilege you should login as root. This means that PHP should post to MySQL root as user and rootpass as password to have all privileges.
2. If connection is successful, your mysql querry should be smth like this
[php]$query = mysql_query('show databases;');[/php]
This will show all databases available on the server.
3. The results you should load in a <SELECT> element as <OPTION>s. This is done using some loop as foreach, while or for...depends on your choice.
Note in order to submit the form without GO button, you should make it like this
[html]<SELECT name="dbselec" onchange="document.form.submit()">[/html]
For each option you should insert a value like this:
e.g. you have loaded your results from the querry into $result wich holds the databases.Option should look like this
[php]echo '<option value="'.$result.'">'.result.'</option>';[/php]
4. When selected, the value will be submitted to next php script, wich will make another query using one of the following methods.
A. [php]$selectDB=mysql_select_db($option.value.from.previous.page);[/php]
B. [php]$query=mysql_query('show tables;');[/php]
OR
[php]$query = mysql_query('show tables from '.$option.value.from.previous.page.';');[/php]
5. Load the results the same way you loaded the result from the first query.
6. Now, I don't get it clear - if you want to view the table content or view the table structure.
A to view the table structure folow the above instructions to make the query, however the query should be like this:
[php]$query=mysql_query('describe table.'$table_name_from_previoust_page'.;');[/php]
OR
B. To view all records, your query should be:
[php]$query = mysql_query('SELECT * FROM'.$table_name_from_previous_page.';');[/php]
That's all. You should learn yourself how to display the results on your page. If I give you the complete script as it should look like, you'll never learn a thing, so forgive me not giving you all ready-made.

Good luck with learning!
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
0
#6 29 Days Ago
Hi guys i m facing a problem with drop down box the condition is i have some entries in my database like some country names & i m executing a query to findout user's selected country from that DB so now i want to show all country names in a single drop down with that particular user's selected country is show "SELECTED"
![]() |
Similar Threads
- How can I send variables from a PHP script to another URL using POST without......... (PHP)
- How many clients can access a PHP script at a time? (PHP)
- how to find stock information with php script (PHP)
- need help with PHP Script translation (PHP)
Other Threads in the PHP Forum
- Previous Thread: How to set up a registration account by PHP
- Next Thread: Editable Table
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dropdown dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube





