[Pugged] Switch Troubles

David Champion ciapug@ciapug.org
Mon, 24 Mar 2003 15:14:57 -0600


Simpler (pseudo) code:

$x = 0;
for ... {
   $x++
   if ($x == 1) {
     $bgcolor = "#aaaaaa";
     $x = 0;
   } else {
     $bgcolor = $defcolor;
   }
   //...yada yada yada
   $rs->MoveNext();
}

Chris Van Cleve wrote:
> I wrote the following code to change the background color of every 
> other line in a table. For some reason, only the default color is ever 
> assigned. Any ideas?
> 
> <?php while (!$result3->EOF) {
>    		for ($i=0; $i < $max; $i++);
> 			$last2 = $str{strlen($i)-1}; 
> 			switch ($last2) { 
> 			case "1":
> 			case "3":
> 			case "5":
> 			case "7":
> 			case "9":
> 			    $bgcolor = "#e1e1e1";
> 				break;
> 			default:
> 			    $bgcolor = "#f5f5f5";
> 			} ?>
> 		  <tr bgcolor="<?= $bgcolor ?>">
> 		  <td><?= $result3->fields['team_name'] ?></td>
> 		  <td><?= $result3->fields['team_position'] ?></td>
> 		  <td><?= $result3->fields['team_phone'] ?></td>
> 		  <td><?= $result3->fields['team_email'] ?></td>
> 		  </tr>
>       <?php $result3->MoveNext();
> 	  } ?>
>