Php Help

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by Ainokea, Sep 18, 2008.

  1. Ainokea

    Ainokea New Member

    Messages:
    127
    Likes Received:
    0
    Trophy 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?
    
    
     
  2. carsec

    carsec New Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    can u show full code
     
  3. mattura

    mattura Member

    Messages:
    570
    Likes Received:
    2
    Trophy 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: Sep 19, 2008
  4. Ainokea

    Ainokea New Member

    Messages:
    127
    Likes Received:
    0
    Trophy Points:
    0
    this is pseudocode... but thanks for the concern
     
  5. mattura

    mattura Member

    Messages:
    570
    Likes Received:
    2
    Trophy 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: Sep 24, 2008

Share This Page