Displaying database records in unordered list format
Just keep a counter, increment it in the loop, and if it's an odd number set class to odd, if even set class to even.
$result = "";
$count = -1;
while ( $row = mysql_fetch_assoc( $query) ) {
$class = $count++ % 2 === 0 ? "even" : "odd" ;
$href = $row["url"];
$text = $row["name"];
$output .= "<li class='{$class}'><a href='foo?id={$href}'>{$name}</a></li>";
}
echo "<ul>{$result}</ul>";