db = MySQLdb.connect(host="127.0.0.1",user="root",passwd="",db="houses")
cursor = db.cursor()
cursor.execute("SELECT * FROM HOME")
rows = cursor.fetchall()
for row in rows:
print row
db.close()
the above is my .py for querying my database set up in xampp with phpadmin
sql! i have a drop down menu in my html and this cgi returns all the
information from my "Home" table. I want to my usr choice to correspond with
the row in my database and not to return all the info only what the user is
looking for. lets say my drop down menu is home1,home2.home3 and usr selects
home1 how do i code that just the information with home1 returns??
please help!!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yes sorry looking at my comment -not much sense made! basically I have a html
page with a drop down list. I then created my phpadmin database (xampp-sql)
and populated the database. so lets say you go to my webpage and there is a
drop down list of choices say: house1,house2,house3 and as a user you select
on one of these options(lets say house2) and you get back information just
regarding house2(this information is what I have set up on the database-lets
say on a table called HOME)
Then I set up my cgi. and from my cgi I cal call all the info on HOME table
but what I want is to correspond each option to the user with the row of
information the user choice is link to. so for each option on my drop down
menu I want a cgi to assign each option with the specific information(home1 is
a row on the HOME table and if the user selects home1 I want it to return
information regarding only home1 so essentially I will be returning a row of
information)
?????? reallystuck.com!!! and would appreciate help!!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi thanks for your help - it turns out that the problem was with the phpadmin
database...thanks again.
however I do have another question. On my html I have multiple drop down
menus. the user must choose the two options from two drop down menus and then
click on 'submit'.
so lets say the html is : choice 1: houseA>houseB>houseC(this is the list)
choice 2: Red>Blue>green
user must select an option from both lists and then click submit to get
information back.
what would be the sql command for this??
in the cgi would I first assign the names : my_usr_choice=form.value ????
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
would you know an SQL statement to search a whole database?
il create a simple search box in html and then connect it to a cgi with an sql
statement to search all of my database in phpadmin depending on what the user
is looking for. if the user types in house1 and clicks search they will get a
return on all info with house1 from the database??
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
form = cgi.FieldStorage()
my_usr_mutation=form.value
db = MySQLdb.connect(host="127.0.0.1",user="root",passwd="",db="houses")
cursor = db.cursor()
cursor.execute("SELECT * FROM HOME")
rows = cursor.fetchall()
for row in rows:
print row
db.close()
the above is my .py for querying my database set up in xampp with phpadmin
sql! i have a drop down menu in my html and this cgi returns all the
information from my "Home" table. I want to my usr choice to correspond with
the row in my database and not to return all the info only what the user is
looking for. lets say my drop down menu is home1,home2.home3 and usr selects
home1 how do i code that just the information with home1 returns??
please help!!
SELECT home1 FROM HOME
?
yes sorry looking at my comment -not much sense made! basically I have a html
page with a drop down list. I then created my phpadmin database (xampp-sql)
and populated the database. so lets say you go to my webpage and there is a
drop down list of choices say: house1,house2,house3 and as a user you select
on one of these options(lets say house2) and you get back information just
regarding house2(this information is what I have set up on the database-lets
say on a table called HOME)
Then I set up my cgi. and from my cgi I cal call all the info on HOME table
but what I want is to correspond each option to the user with the row of
information the user choice is link to. so for each option on my drop down
menu I want a cgi to assign each option with the specific information(home1 is
a row on the HOME table and if the user selects home1 I want it to return
information regarding only home1 so essentially I will be returning a row of
information)
?????? reallystuck.com!!! and would appreciate help!!
Not sure if I inderstood right, but there's some info missing here. Isn't it
just basic SQL?
hi thanks for your help - it turns out that the problem was with the phpadmin
database...thanks again.
however I do have another question. On my html I have multiple drop down
menus. the user must choose the two options from two drop down menus and then
click on 'submit'.
so lets say the html is : choice 1: houseA>houseB>houseC(this is the list)
choice 2: Red>Blue>green
user must select an option from both lists and then click submit to get
information back.
what would be the sql command for this??
in the cgi would I first assign the names : my_usr_choice=form.value ????
You would need to extract both values from your form, something like:
and they call with something like:
Perhaps, have a look at the API: http://mysql-
python.sourceforge.net/MySQLdb-1.2.2/
thats great thanks you !!
would you know an SQL statement to search a whole database?
il create a simple search box in html and then connect it to a cgi with an sql
statement to search all of my database in phpadmin depending on what the user
is looking for. if the user types in house1 and clicks search they will get a
return on all info with house1 from the database??
This is getting out of the scope of using MySQLdb. I would suggest you to
learn SQL first.