#!c:/Python32/python.exe -u
import cgi
import cgitb
import mysql.connector
cgitb.enable()

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

print('<html>')
print('<head>')
print('<title>PytoCms - Content management System</title>')
print('<link rel="stylesheet" href="style.css">')
print('</head>')
print('<body>')
print('<div class="div_menu"><ul class="menu">')

data = mysql.connector.connect(user = 'root', database = 'pytocms')
cursor = data.cursor()
cursor.execute('SELECT name,link FROM menu')
result = cursor.fetchall()
for NAME,LINK in result:
    print('<li><a href="',LINK,'">',NAME,'</a></li>')
cursor.close()

print('</ul></div>')
print('<div class="header" align="left"></div>')

cursor = data.cursor()
cursor.execute('SELECT name,text,image FROM news')
result = cursor.fetchall()

for NAME,TEXT,IMAGE in result:
    print('<div class="main"><h3><img src="',IMAGE,'" width="90" height="90" align="right"/>',NAME,'</h3><p>',TEXT,'<p></div>')
cursor.close()
print('</body>')
print('</html>')
