خرید بک لینک

Vote count: 0

Im creating a shop page as my college project. I have a database set up and Im trying to use the select and submit to open a new page which will display information about the selected part. I just cant seem to be able to extract data from the database, can you help please ?

That's a part of my html

<p class="heading2">List of CPU's:</p>
<form action="show_part.py">
<select name="component">
    <option value="Intel_i7-5960x">Intel i7-5960x</option>

Then this is the python

#!/usr/local/bin/python3

from cgitb import enable
import pymysql as db
from cgi import FieldStorage

print('Content-Type: text/html')
print()

form_data = FieldStorage()
component = form_data.getfirst("name")

result=''
try:
    coection = db.coect('***', '***', '***', '***')
    cursor = coection.cursor(db.cursors.DictCursor)
    result += cursor.execute("""SELECT price 
                                FROM components
                                WHERE name = %s""" % (component))
    coection.close()
except db.Error:
result = '<p>Sorry! We are experiencing problems at the moment. Please call back later.</p>'

print("""
<!DOCTYPE html>
    <html lang="en">
        <head>
            <title>Part details</title>
        </head>
        <body>
            %s
        </body>
        </html>""" % (result))

What happens is I keep getting the error message in the new page, meaning the code is fine, just something about the database query. Any suggestions ?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 21 فروردين 1395 ساعت: 20:23

صفحه بندی