codice:
$cont = 0;

while($riga = mysql_fetch_array($obj, MYSQL_ASSOC))
{
   $classe = ((++$cont % 2) == 0)? 'pari' : 'dispari';

    if($riga['immagine'] == NULL)
    {
        $img = "N/D";
    }
    else
    {
        $img = $riga['immagine'];
    }
    htmlentities($riga['campo1']);
    htmlentities($riga['campo2']);
    htmlentities($riga['campo3']);
    htmlentities($riga['campo4']);
    echo "\t\t\t\t\t" . '<tr class = "'. $classe .'">'. "\n";
    echo "<td>".$riga['ID'].
    "</td>\n<td>".$riga['campo1'].
    "</td>\n<td>".$riga['campo2'].
    "</td>\n<td>".$riga['campo3'].
    "</td>\n<td>".$riga['campo4'].
    "</td>\n<td>".$img."</td>\n";
    echo "\t\t\t\t\t</tr>";
}


sposto su php