แต่พอไปดูหน้า show ตารางมาแล้วแต่ข้อมูลยังไม่มา
code
โค้ด: เลือกทั้งหมด
@app.route('/show')
def show():
try:
con = p.connect(host='127.0.0.1', database='miniproject', user='postgres', password='', port='5432')
cur = con.cursor()
sql = "SELECT * FROM genpdf ORDER BY id DESC LIMIT 10"
sql = sql.encode('utf-8')
cur.execute(sql)
rows = cur.fetchall()
for row in rows:
name = row[0]
des = row[1]
except p.DatabaseError:
print ('Error %s' % p.DatabaseError)
return render_template("show.html")
โค้ด: เลือกทั้งหมด
<meta charset="UTF-8">
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>แสดงข้อมูล</title>
</head>
<body>
<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>