PDA

View Full Version : Every Second Result


Adrian Schneider
02-04-2005, 03:33 AM
For a mySQL query, how would you make every second result different (such as 2 different styles)?

if ($_REQUEST['do'] == 'maps')
{
if (is_member_of($bbuserinfo, 6) OR is_member_of($bbuserinfo, 19))
{
$getmaps=$DB_site->query("SELECT * FROM maps");
while($maps=$DB_site->fetch_array($getmaps))
{
$mapid = $maps['id'];
$mapname = $maps['name'];
$mapheight = $maps['height'];
$mapwidth = $maps['width'];
$maptileset = $maps['tileset'];
$mapimage = $maps['image'];
$mapauthor = $maps['author'];
$mapstacked = $maps['stacked'];
$mapplayers = $maps['players'];
$mapauthoremail = $maps['authoremail'];
$mapfile = $maps['file'];
$mapdescription = $maps['description'];
eval('$downloads_mapsbit .= "' . fetch_template('downloads_mapsbit') . '";');
}
eval('print_output("' . fetch_template('downloads_maps') . '");');
}
}

Thanks.

Jolten
02-04-2005, 04:57 AM
if ($_REQUEST['do'] == 'maps')
{
if (is_member_of($bbuserinfo, 6) OR is_member_of($bbuserinfo, 19))
{
$getmaps=$DB_site->query("SELECT * FROM maps");
while($maps=$DB_site->fetch_array($getmaps))
{

if($col %2 == 0) {
$color='alt1';
}else{
$color='alt2';
}
$mapid = $maps['id'];
$mapname = $maps['name'];
$mapheight = $maps['height'];
$mapwidth = $maps['width'];
$maptileset = $maps['tileset'];
$mapimage = $maps['image'];
$mapauthor = $maps['author'];
$mapstacked = $maps['stacked'];
$mapplayers = $maps['players'];
$mapauthoremail = $maps['authoremail'];
$mapfile = $maps['file'];
$mapdescription = $maps['description'];
eval('$downloads_mapsbit .= "' . fetch_template('downloads_mapsbit') . '";');
$col++;
}
eval('print_output("' . fetch_template('downloads_maps') . '");');
}
}


Then in your downloads_maps template add <tr class="$color"> to the row. They will alternate. You can expand on this to ad table cell classes, font tags, whatever you need.

miz
02-04-2005, 05:02 AM
btw i think that if you will use list its will be much better..

Adrian Schneider
02-04-2005, 10:15 PM
Thanks Jolten works marvelously.

miz: list instead of what?