note 74631 deleted from control-structures.for by tularis

From: Date: Fri, 20 Apr 2007 21:27:29 +0000
Subject: note 74631 deleted from control-structures.for by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-125719@lists.php.net to get a copy of this message
Note Submitter: jrgpmaster at gmail dot com Reason: useless ---- This is an even easier method of using alternating row colors using the 'for' statement. <?php echo ' <style type="text/css"> .alt { background-color: #ccc; } '; $sql = mysql_query("select * from users"); echo '<table>'; echo '<tr><th>Name</th></tr>'; for ($i = 0; $u = mysql_fetch_array($sql); $i++) { $row_color = ($i % 2) ? 'alt' : ''; echo ' <tr class="'.$row_color.'"> <td>'.stripslashes($u['name']).'</td> </tr> '; } echo "\n</table>"; ?>

« previous php.notes (#125719) next »