PDA

View Full Version : alternating row color


DjSap
02-27-2002, 11:36 AM
Im trying to make a classifieds hack for my board and i want to list all results in a table, it works fine but i can't get the row colors to alternate so that both second and firstaltcolor is used, ive tried to do it according to some tutorials but it doesnt seem to work on vb.

This is my query for displaying a list of the ads


$clsbit = $DB_site->query("SELECT adid, price, userid, title, timeline, category FROM classified ORDER BY adid DESC LIMIT 5");
while ($admessage=$DB_site->fetch_array($clsbit)) {
$adid = $admessage[adid];
$userid = $admessage[userid];
$date = vbdate("m-d-Y H:i",$admessage[timeline]);;
$title = $admessage[title];
$price = $admessage[price];
$catid = $admessage[category];
$userinfo=getuserinfo($userid);
$cat=$DB_site->query("SELECT category FROM classified_category WHERE catid='$catid'");
list($category) = mysql_fetch_row($cat);
eval("\$classifiedbit .= \"".gettemplate("classifiedbit")."\";");
}

So could someone tell me what i should write to get alternating row colors working.

Admin
02-27-2002, 12:05 PM
See my thread in the Hints and Tips forum.

mrbaseball34
09-04-2002, 02:34 PM
You mentioned a thread about alternating row colors in the
hints/tips forum but I could not find it.

I'd like to replace my XMB board with a VBulletin board but want to keep the same scheme, like the screenshot below.

http://www.austinmetrobaseball.com/board/images/AMBL/screenshot.gif

tHE DSS
09-04-2002, 05:10 PM
For anything like this, you can use a function similar to the following :


// check if value is EVEN function
function isEven($value) {
return $result = ($value % 2 == 0) ? (true) : (false);
}

// usage example
$counter = 0;
while ($counter++ <= 10) {
if (isEven($counter)) {
// counter is an EVEN number, output, BLAH BLAH #01
} else {
// counter is NOT EVEN number, output BLAH BLAH #02
}
}


... basically, doing a 'modulus' operator divides 'x' by 'y', and returns the remainder.... as be do a modulus 2, if the number is not directly divisable by 2 (doesn't return a remainder of 0), then the number is not even, otherwise, it is.

Using that technique, you can display alternate stuff, depending on a counter being ODD or EVEN.

mrbaseball34
09-05-2002, 12:53 PM
I *know* how to do it, it's just *where* in the vB code I need to.

As you can see, I was able to do it to XMB. FireFly posted that
he had a completed mod and I couldn't find the post. I was just
asking where to get the mod...