Re: Alternating rows pulled from database

From: Date: Thu, 29 Nov 2001 15:53:25 +0000
Subject: Re: Alternating rows pulled from database
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-76046@lists.php.net to get a copy of this message
can it be index_forum1 instead of index_forum. This code presumes that it's possible while($group = $db->fetch_array($queryg)) { if($group[type] == "group") { $bg = 1- $bg; eval("\$forumlist .= \"".template("index_category".($bg+1)."\";"); if($catsonly != "on" || $gid) { $query = $db->query("SELECT * FROM $table_forums WHERE type='forum' AND status='on' AND fup='$group[fid]' ORDER BY displayorder"); while($forum = $db->fetch_array($query)) { $forumlist .= forum($forum, "index_forum"); } } }else { $forumlist .= forum($group, "index_forum"); } } Regards Andrey Hristov ----- Original Message ----- From: "MrBaseball34" <mrbaseballthirtyfour@hotmaildot.com> To: <php-db@lists.php.net> Sent: Thursday, November 29, 2001 5:31 PM Subject: [PHP-DB] Alternating rows pulled from database > I am trying to modify the XMB Forums to be more like > UBB in looks. > > In this code, I want to alternate forum_index templates. > > I have created two templates, one using $altbg1 and one using $altbg2. I want > to alternate the row colors... > > How would I accomplish that? > {from: index.php} > > code: > while($group = $db->fetch_array($queryg)) { > if($group[type] == "group") { > eval("\$forumlist .= > \"".template("index_category")."\";"); > if($catsonly != "on" || $gid) { > $query = $db->query("SELECT * FROM $table_forums WHERE type='forum' > AND status='on' AND fup='$group[fid]' ORDER BY > displayorder"); > while($forum = $db->fetch_array($query)) { > $forumlist .= forum($forum, "index_forum"); > } > } > }else { > $forumlist .= forum($group, "index_forum"); > } > } > > > What I really need to do is something like this: > > $i = 0 > while($forum = $db->fetch_array($query)) { > if ($i % 2 = 0 { > $forumlist .= forum($forum, "index_forum"); > } else { > $forumlist .= forum($forum, "index_forum2"); > } > $i = $i + 1; > } > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#76046) next »