[Tutor] Values being skipped-Iteration
Sharriff Aina
NHYTRO@compuserve.com
Mon, 14 May 2001 02:23:21 -0400
Hi guys!
I=B4m retrieving values from a databse:
## code start ##
# database access for side navigation for individual editors
## ------------------------------------------------------
connection =3D odbc.odbc('minicms')
cur =3D connection.cursor()
cur.execute("select navlinks from users where username =3D'%s'"
%(usernamevalue))
alllinks =3D cur.fetchall()
cur.close()
connection.close()
###
I generate chunks of HTML depending on what I get from these values:
### code start ###
templinks =3D alllinks[0]
links =3D string.split(templinks[0],",")
for x in links[:]:
if x =3D=3D "Home": =
counter =3D counter + 1
print '<td><img src=3D"check-blank.jpg" name=3D"homestatus"><=
/td>'
print '<td bgcolor=3D"#F7DF89">',
print x
print """
</td>
<td><input type=3D"button" onclick=3D"edithome(),homechecked(=
);"
value=3D"edit"</td>
</tr>
<tr>
""" =
elif x =3D=3D "Aktuelles": =
counter =3D counter + 1
print '<td><img src=3D"check-blank.jpg"
name=3D"aktuellesstatus"></td>' =
print '<td bgcolor=3D"#F7DF89">',
print x
print """
</td>
<td><input type=3D"button"
onclick=3D"editaktuelles(),aktuelleschecked();" value=3D"edit"</td>
</tr>
<tr>
..."""
##
-------------------------------------------------------------------------=
--
----------
## this goes on for all the ten checkboxes on the HTML form
##
-------------------------------------------------------------------------=
--
-------------
my problem is very embarassing, the loop skips values it always generates=
the first chunk it gets, but if values are skipped on the form (example:
choosing checkbox 1, 2 ,6) the HTML chinks 1 and 2 would be printed but n=
ot
6!! if one chooses all of the checkboxes without any gaps the loop works.=
I thought that getting rid of the 'Nones's in the database fields would
help, nogo, I have re-written the above loop at least 6 times but I still=
cant get the" hiccups" out.
Could someone give me a helping hand?
Thanks
Sharriff
=