Kreirajmo prvo malo CSS stilova:
<style type="text/css">
table{border-collapse: collapse; border: 1px solid #666666;}
td{padding:5px;}
.par{background-color:#cccccc;color: #333333;}
.nepar{background-color:#e2e2e2;}
</style>
S obzirom da nisi naveo kako izgleda polje u php-u pretpostavimo da je ovako:
$rows = array(
'1'=>array(
'id' => 1,
'ime' => 'ime',
'prezime' => 'prezime',
'adresa' => 'adresa',
'telefon' => 'telefon',
'mail' => 'mail',
'web' => 'web'
),
'2'=>array(
'id' => 2,
'ime' => 'ime',
'prezime' => 'prezime',
'adresa' => 'adresa',
'telefon' => 'telefon',
'mail' => 'mail',
'web' => 'web'
),
'3'=>array(
'id' => 3,
'ime' => 'ime',
'prezime' => 'prezime',
'adresa' => 'adresa',
'telefon' => 'telefon',
'mail' => 'mail',
'web' => 'web'
),
'4'=>array(
'id' => 4,
'ime' => 'ime',
'prezime' => 'prezime',
'adresa' => 'adresa',
'telefon' => 'telefon',
'mail' => 'mail',
'web' => 'web'
),
'5'=>array(
'id' => 5,
'ime' => 'ime',
'prezime' => 'prezime',
'adresa' => 'adresa',
'telefon' => 'telefon',
'mail' => 'mail',
'web' => 'web'
)
);
I na kraju ispiši tablicu ovako:
$i=0;
echo '<table>
<thead>
<tr>
<th>id</th>
<th>ime</th>
<th>prezime</th>
<th>adresa</th>
<th>telefon</th>
<th>mail</th>
<th>web</th>
</tr>
<thead>';
foreach ($rows as $row){
$class = ($i%2==0) ? 'par' : 'nepar';
echo '
<tr class="'.$class.'">
<td>'.$row['id'].'</td>
<td>'.$row['ime'].'</td>
<td>'.$row['prezime'].'</td>
<td>'.$row['adresa'].'</td>
<td>'.$row['telefon'].'</td>
<td>'.$row['mail'].'</td>
<td>'.$row['web'].'</td>
</tr>';
$i++;
}
echo '</table>';