Τη Κυριακή, 27 Ιανουαρίου 2013 8:36:42 μ.μ. UTC+2, ο χρήστης Joel Goldstick 
έγραψε:
> On Sun, Jan 27, 2013 at 1:05 PM, Κώστας Παπαδόπουλος <nikos...@gmail.com> 
> wrote:
> 
> Τη Κυριακή, 27 Ιανουαρίου 2013 6:12:59 μ.μ. UTC+2, ο χρήστης ru...@yahoo.com 
> έγραψε:
> 
> 
> 
> 
> > On 01/27/2013 02:04 AM, Ferrous Cranus wrote:
> 
> >
> 
> > >[...]
> 
> >
> 
> > >             data = cur.fetchall()
> 
> >
> 
> > >             for row in data:
> 
> >
> 
> > >                     print ( "<tr>" )
> 
> >
> 
> > >
> 
> >
> 
> > >                     for item in row:
> 
> >
> 
> > >                             print( '''<td>  <a 
> > > href='http://www.%s?show=log'>%s</a>  </td>''' % (item, item) )
> 
> 
> >
> 
> > >[...]
> 
> >
> 
> > > Okey, so far BUT i want the url linking to happen only for the URL 
> > > column's
> 
> >
> 
> > > value, and not for the hits column too. How do i apply the url link to the
> 
> >
> 
> > > URL column's value only?
> 
> >
> 
> >
> 
> >
> 
> > Ferrous,
> 
> >
> 
> >
> 
> >
> 
> > 'row' has two items (the url and the hit count) in it, right?
> 
> >
> 
> > So print each separately rather than in a loop:
> 
> >
> 
> >
> 
> >
> 
> >     data = cur.fetchall()
> 
> >
> 
> >     for row in data:
> 
> >
> 
> >       url = row[0]
> 
> >
> 
> >       hits = row[1]
> 
> >
> 
> >         print ( "<tr>" )
> 
> >
> 
> >         print( "<td>  <a href='http://www.%s?show=log'>%s</a>  </td>: % 
> > (url, hits) )
> 
> 
> 
> Yes that can work, but i want to ask you if its possible to do the same thing 
> from within the loop as i have it coded it until now.
> 
> 
> 
> Is there a way to seperate the values within the loop?
> 
> 
> 
> for row in data:
> 
>     print( "<td>  <a href='http://www.%s?show=log'>%s</a>  </td>: " % 
> (row[0], row[1]) )

This is not correct.
the <a href> attribute is for url (row[0]) only, not for url and hits too.

i want the following working code:

=============
                data = cur.fetchall()
                for row in data:
                        url = row[0]
                        hits = row[1]
                        print ( "<tr>" )
                        print( "<td>  <a href='http://www.%s?show=log'>%s</a>  
</td>" % (url, url) )
                        print( "<td><b> %s </td>" % (hits) )
=============

inside the loop i posted initially, if its possible.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to