+ Reply to Thread
Results 1 to 5 of 5

Thread: Php Help

  1. #1
    Ainokea is offline x10 Sophmore Ainokea is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    127

    Php Help

    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. #2
    carsec is offline x10Hosting Member carsec is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    2

    Re: Php Help

    can u show full code

  3. #3
    mattura's Avatar
    mattura is offline x10 Elder mattura is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    563

    Re: Php Help

    It doesn't work because you set s=0, then test if s==0!!!!
    Also, you need $ sign for variables, and semi colons

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

    Last edited by mattura; 09-19-2008 at 03:44 AM.
    ----
    Life is a game. The conception is terrible but the graphics are amazing!
    matt.elementfx.com

  4. #4
    Ainokea is offline x10 Sophmore Ainokea is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    127

    Re: Php Help

    this is pseudocode... but thanks for the concern

  5. #5
    mattura's Avatar
    mattura is offline x10 Elder mattura is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    563

    Re: Php Help

    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 by mattura; 09-24-2008 at 05:50 PM. Reason: Automerged Doublepost
    ----
    Life is a game. The conception is terrible but the graphics are amazing!
    matt.elementfx.com

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  4. php errors galore
    By DMG Online in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 05-17-2008, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers