/    Sign up×
Community /Pin to ProfileBookmark

populate drop down from mysql

hello

i have 2 drop down list..

first i want to populate from mysql databases names using commnad “show databases “

second drop down i wanna populate from above selected dataabse..
like if dropdown list1 shows “IT” then

for dropdownlist2

command for populating should be “use IT;”

“show tables”..

the result should populate the dropdownlist2….

how can i do this?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmSep 12.2014 — Do you want to do this in two passes? That is, the user selects one db and submits the form and you take that and php re-builds the page with the first dropdown showing the selected database and the 'new' second dropdown shows the tables within the selected database? That would be the easy way.

(Note how I took the time to write properly spelled words and well structured sentences in order to make my point clear. It took me 3 readings to interpret your scenario.)
Copy linkTweet thisAlerts:
@ankit1122authorSep 12.2014 — sorry for english not our official language

as soon as i select a db from dropdown list1 it should show the tables inside that db onto dropdownlist2 without submitting the form...ajax will be used..
Copy linkTweet thisAlerts:
@ginerjmSep 12.2014 — Sorry for abusing you. Thought English was your language. Keep at it!

So you want an immediate response - that entails an ajax call. Some js code that gets triggered when the first dropdown changes. That js code calls the server to run a php script that returns the 'options' code for the second dropdown. Go for it!
Copy linkTweet thisAlerts:
@ankit1122authorSep 13.2014 — how does js calls server side php document as js is a client side scripting language
Copy linkTweet thisAlerts:
@ginerjmSep 13.2014 — YOu setup a JS or JQ function that gets called by an html event. That code makes a url call that executes the php script which then returns a value (string?) which you then paste into the other dropdown just like you did when you built the page with the first dropdown. There are many good examples of an ajax call on the net.
×

Success!

Help @ankit1122 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...