Return to Snippet

Revision: 49595
at July 26, 2011 02:21 by Darksider3

Initial Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>Abwechselnde Zeilenfarben(MYSQL)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
    font-family:      Verdana,Arial,sans-serif;
    font-style:       normal;
    font-size:        14px;
    BORDER-TOP:       #A6A6A6 1px solid;
    BORDER-LEFT:      #A6A6A6 1px solid;
    BORDER-BOTTOM:    #A6A6A6 1px solid;
    BORDER-RIGHT:     #A6A6A6 1px solid;
.row_0 {
    background-color:        #FFFFFF;
.row_1 {
    background-color:        #E1E8F1;
<table width="100%" border="0" cellpadding="0" cellspacing="0"
    class="tableLine" height="100%">
mysql_connect(''localhost'', ''root'', ''****'');
$sql = mysql_query(''SELECT * FROM news'');
while($res=  mysql_fetch_array($sql)){
    if($res[''id''] % 2){
        echo "<tr><td class=''row_0''>Eintrag nr. $res[id]<br />$res[text]</td></tr>";
    else {
        echo "<tr><td class=''row_1''>Eintrag nr. $res[id]<br />$res[text]</td></tr>";
echo "</table>";

Initial URL

Initial Description
Here you see a example to make your table background color fdifferent at last

Initial Title
Make your table color different by Mysql Select tag

Initial Tags
mysql, php, table, html, color

Initial Language