Wed Development - Dynamically Generated News Index

infidel02 at infidel02 at
Tue Dec 20 23:01:53 CET 2005

Hi Jean-Paul,

The truth of the matter is that I was hoping that this could be
accomplished using pure CGI.

I am considering wether I need to learn these new frameworks, but I am
in somewhat of a hurry.

Also I have this problem with this simple test script that I have
written.  It pulls the infromation from the database correctly, but is
printing out the html tags in the browser, not sure what is wrong:



# import MySQL module
import MySQLdb, cgi

# connect
db = MySQLdb.connect(host="localhost", user="nancy",

# create a cursor
cursor = db.cursor()

# execute SQL statement
cursor.execute("SELECT * FROM news where storyDATE < '2005-10-1';")

# get the resultset as a tuple
result = cursor.fetchall()


print """ Content-Type: text/html\n\n

          <title>DB Test</tile>




# iterate through resultset
for record in result:

    print """<h1>%s</h1>



           """ %(record[1],record[2],record[3])

print   """






          <title>DB Test</tile>



<h1>Heading 4</h1>

             <p>Body 4</p>


<h1>Heading 5</h1>

             <p>Body 5</p>


<h1>Heading 6</h1>

             <p>Body 6</p>



More information about the Python-list mailing list