March 5th, 2004, 09:19 PM
I'm trying to dynamically populate a dropdown fom a database MySQL db using Python. I am stuck. Can somebody please help on how to get started or point in right direction? Thanks in advance!
March 5th, 2004, 10:44 PM
so what exactly don't you understand? you grab the info out of the db and write it in the HTML form.
March 6th, 2004, 07:34 AM
As 2k said, there isn't really a lot to get stuck on here but anyway here's a little example - this doesn't use any db since i don't have any data to populate this t with.
Note: 'values' can be a simple cursor or list/tuple object. needs a little reworking if you want to use dictionaries but it shows you exactly what you need.... so, a loop
print 'Content-Type: text/html\n'
values = ['Name1', 'Name2', 'Name3', 'Name4']
for value in values:
print'<option>%s</option>' % value
March 19th, 2004, 12:48 PM
Thanks netytan. I kinda figured out myself but appreciate your example!
Originally Posted by netytan