I need to...

Discussion in 'PHP' started by terryuk, May 12, 2007.

  1. #1
    I'm making a table off results from a mySQL database, to make the table more readable i'm trying to make every other row light grey while the others are white..

    I'm only using mysql_fetch_array to get the data... can anyone help me please?
     
    terryuk, May 12, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    
    $color = 'white';
    
    while (/* condition */)
    {
        $color = $color == 'grey' ? 'white' : 'grey';
    
        echo $color;
    }
    
    
    PHP:
     
    nico_swd, May 12, 2007 IP
    terryuk likes this.
  3. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #3
    I've been looking for this too, and excuse the amateur question, but what goes here?
    /* condition */
    PHP:
    Could I have an example?

    Thanks!

    -Peter
     
    dp-user-1, May 12, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Your loop condition. Usually something like: (when looping through a table)
    
    while ($row = mysql_fetch_array($query))
    
    PHP:
     
    nico_swd, May 12, 2007 IP
  5. terryuk

    terryuk Notable Member

    Messages:
    3,962
    Likes Received:
    319
    Best Answers:
    0
    Trophy Points:
    255
    #5
    Cool, thanks!! :)
     
    terryuk, May 12, 2007 IP
  6. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #6
    :) Makes sense. Thanks!
     
    dp-user-1, May 13, 2007 IP