|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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!
![]() |
|
#2
|
|||
|
|||
|
so what exactly don't you understand? you grab the info out of the db and write it in the HTML form.
|
|
#3
|
||||
|
||||
|
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.Code:
#!/usr/bin/env python
print 'Content-Type: text/html\n'
values = ['Name1', 'Name2', 'Name3', 'Name4']
print'<form name="form">'
print'<select name="names">'
print'<option selected>Netytan</option>'
for value in values:
print'<option>%s</option>' % value
print'</select>'
print'</form>'
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 ![]() Mark. |
|
#4
|
|||
|
|||
|
Thanks netytan. I kinda figured out myself but appreciate your example!
Quote:
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Populating dropdowns |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|