A snippet, which can help you out alternating table row colors from a array.
$values = array('PHP' => 'Hypertext Preprocessor',
'HTML' => 'Hypertext Markup language',
'SGML' => 'Standard Generalized Markup Language',
'XML' => 'Extensible Markup Language',
'AJAX' => 'Asynchronous JavaScript and XML'
);
// Set count variable to 0
$count = 0;
// Open table element
echo '<table>';
// Create your table rows and cells
foreach ($values as $key => $value)
{
if ($count%2!=0):
$color = '#FF6A00';
else:
$color = '#16A016';
endif;
echo '<tr bgcolor="'.$color.'"><td>'.$key.'</td><td>'.$value.'</td></tr>';
// Count each time 1 to $count
$count++;
}
// Close your table element
echo '</table>';
Mail this!
- Comments (0)
- PingBacks (0)
- TrackBacks (0)

» Latest comments