Jump to content

PHP Alternate row help please


ozone1

Recommended Posts

Hi guys i need a little help to list data in different coloured rows

 

i need to list 1st name in <td class="alt1"> 2nd name in <td class="alt2"> and so on

currently it is listing only in <td class="alt1">

 

here is my code any help really appreciated

 

<?php

 

$result[0] = mysql_query("SELECT * FROM videos ORDER BY viewtoday

DESC LIMIT 10");

 

for($i=0;$i<count($result);$i++) {

echo '';

while($row=mysql_fetch_array($result[$i])) {

$id = $row['id'];

$cat = $row['cat'];

$title = $row['title'];

$numviews = $row['viewtoday'];

 

$max_length = 25;

$title = ( strlen($title) > $max_length ?

substr($title,0,$max_length)."..." : $title );

 

 

echo '<table class="listOfShows listOfShowsFirst"><tr>

<td class="alt1">

<a href="videos.php?id=' . $id . '">'. $title . '</a> </td>

</tr>';

 

}

 

}

 

?>

</table></td></table>/php]

 

Link to comment
https://forums.phpfreaks.com/topic/222597-php-alternate-row-help-please/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.