奇怪甚至在PHP / MySQL中

I want to ask how to set odd or event in mysql->php output. I can do this with that code:

if($i%2 == 0)
{
    $class = 'content';
}
else
{
    $class = 'contents';
}


echo "<tr class='$class'>...

...but if i remove manual a row in the mysql things at output get messed. I'm thinking some way with foreach...or something like that. Any help will be superb.

This will work:

$i = 0;
while ($row = $result->fetch_assoc()) {
    $class = ($i++ % 2) ? 'contents' : 'content';
...
}

If you're trying to alternate on odd and even output lines, I like to use a simple toggle:

$toggle = false;
foreach($items as $item){

  if($toggle){
   ..contents...
  }else{
   ...alternative content....
  }
  $toggle = !$toggle;
}

You can compress this with a ternary comparison if compact code is desired