Date: 11/29/01
- Next message: MrBaseball34: "RE: [PHP-DB] Re: Alternating rows pulled from database"
- Previous message: MrBaseball34: "[PHP-DB] Re: Alternating rows pulled from database"
- Maybe in reply to: Lee Willmann: "[PHP-DB] Re: Alternating rows pulled from database"
- Next in thread: MrBaseball34: "RE: [PHP-DB] Re: Alternating rows pulled from database"
- Reply: MrBaseball34: "RE: [PHP-DB] Re: Alternating rows pulled from database"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Not knowing what else is going on here... at the
very least your row counting variable is inconsistent.
You mention row_count (in the modulus test) and rowcount
(in the initialization and incrementation).
> -----Original Message-----
> From: MrBaseball34 [mailto:mrbaseballthirtyfour <email protected>]
> Sent: Thursday, November 29, 2001 3:34 PM
> To: php-db <email protected>
> Subject: [PHP-DB] Re: Alternating rows pulled from database
>
>
> In article <20011129202122.85089.qmail <email protected>>,
> lwillmann <email protected>
> says...
> > Here's what I did to get alternating row colors on a
> results page... I'm not
> > sure that I follow what you are asking, but I hope this
> will help you:
> >
> >
> > $color_one = "dddddd";
> > $color_two = "cccccc";
> > $row_count = 0;
> > // SEND QUERY
> > while (row = fetch array(result))
> > {
> > $row_color = ($row_count % 2) ? $color_one : $color_two;
> > other fields from DB
> > echo "<tr bgcolor=$row_color">;
> > echo "<td>";
> > echo data out
> > echo "</td>";
> > echo "</tr>";
> > $row_count++;
> > }
> >
> >
> > This is a really simple system. It uses the modulus (%)
> operator. If the
> > result of the math is even it uses color_one otherwise it
> uses color_two..
> >
> > I found it somewhere, can't remember where right now.. But
> at least it works
> > and it's only a few lines of code!!
> >
> <SNIP>
>
> Think this would work?
>
> $rowcount = 0
> while($forum = $db->fetch_array($query)) {
> $forumlist .= ($row_count % 2) ?
> forum($forum, "index_forum") :
> forum($forum, "index_forum2");
> $rowcount++;
> }
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe <email protected>
> For additional commands, e-mail: php-db-help <email protected>
> To contact the list administrators, e-mail:
> php-list-admin <email protected>
>
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: MrBaseball34: "RE: [PHP-DB] Re: Alternating rows pulled from database"
- Previous message: MrBaseball34: "[PHP-DB] Re: Alternating rows pulled from database"
- Maybe in reply to: Lee Willmann: "[PHP-DB] Re: Alternating rows pulled from database"
- Next in thread: MrBaseball34: "RE: [PHP-DB] Re: Alternating rows pulled from database"
- Reply: MrBaseball34: "RE: [PHP-DB] Re: Alternating rows pulled from database"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

