โดย teenproza7 » 24/05/2019 3:19 pm
ผมเรียกข้อมูลจากฐานข้อมูลมาแสดงแล้ว เกิด Error แบบนี้ครับ
code
โค้ด: เลือกทั้งหมด
@app.route('/show')
def show():
cur.execute('SELECT version()')
sql = "SELECT * FROM genpdf ORDER BY fileid DESC LIMIT 3"
sql = sql.encode('utf-8')
cur.execute(sql)
rows = cur.fetchall()
return render_template("show.html", rows=rows)
หน้า html
โค้ด: เลือกทั้งหมด
#-*- coding=utf-8 -*-
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>แสดงข้อมูล</title>
</head>
<fo>
<table border="1" 1cellspacing="5" width="80%" height="5" align="center">
<a href = "/">กลับหน้าหลัก</a>
<thead>
<td align="center">ID</td>
<td align="center">ชื่อไฟล์</td>
<td align="center">คำอธิบาย</td>
<td colspan="2" align="center" width="10%">เครื่องมือ</td>
</thead>
{% for row in rows %}
<tr>
<td>{{ row[0] }}</td>
<td>{{ row[1] }}</td>
<td>{{ row[2] }}</td>
<td> <form action="/iddel/{{ row[0] }}" method="post"> <input type="submit" value="ลบข้อมูล" /> </form></td>
<td><form action="/enteredit/{{ row[0] }}" method="post"> <input type="submit" value="แก้ไข" /> </form></td>
</tr>
{% endfor %}
</table>
</body>
</html>
ผมเรียกข้อมูลจากฐานข้อมูลมาแสดงแล้ว เกิด Error แบบนี้ครับ
[img]http://snap.mindphp.com/index.php?view=2019May24_5ce7a6430a744[/img]
code
[code]@app.route('/show')
def show():
cur.execute('SELECT version()')
sql = "SELECT * FROM genpdf ORDER BY fileid DESC LIMIT 3"
sql = sql.encode('utf-8')
cur.execute(sql)
rows = cur.fetchall()
return render_template("show.html", rows=rows)[/code]
หน้า html
[code]
#-*- coding=utf-8 -*-
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>แสดงข้อมูล</title>
</head>
<fo>
<table border="1" 1cellspacing="5" width="80%" height="5" align="center">
<a href = "/">กลับหน้าหลัก</a>
<thead>
<td align="center">ID</td>
<td align="center">ชื่อไฟล์</td>
<td align="center">คำอธิบาย</td>
<td colspan="2" align="center" width="10%">เครื่องมือ</td>
</thead>
{% for row in rows %}
<tr>
<td>{{ row[0] }}</td>
<td>{{ row[1] }}</td>
<td>{{ row[2] }}</td>
<td> <form action="/iddel/{{ row[0] }}" method="post"> <input type="submit" value="ลบข้อมูล" /> </form></td>
<td><form action="/enteredit/{{ row[0] }}" method="post"> <input type="submit" value="แก้ไข" /> </form></td>
</tr>
{% endfor %}
</table>
</body>
</html>
[/code]