Php Help

Ainokea

New Member
Messages
127
Reaction score
0
Points
0
I was making a php/mysql news based system so I was trying to display the content on the admin page..
Im displaying the table, but I want each row to be like a different background color, so its easier to see...

I tried
Code:
s=1
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
if(s==1)
   my code....
  s=0;
if(s==0)
  my code...
s=1
}

but it didn't work any ideas why?
 

mattura

Member
Messages
570
Reaction score
2
Points
18
It doesn't work because you set s=0, then test if s==0!!!!
Also, you need $ sign for variables, and semi colons

PHP:
$s=1;
while($row = mysql_fetch_assoc($result))
{
 if($s==1) {
    my code....
    $s=0;
 } else {
   my code...
   $s=1;
 }
}
 
Last edited:

mattura

Member
Messages
570
Reaction score
2
Points
18
Well it looks like php to me...and the topic is 'php help'

Anyway. I gave you your answer. You need to have 'else', not a second 'if'
Edit:
did you read the first line of my reply above? Or take a closer look at the code? ;)
 
Last edited:
Top