#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    392
    Rep Power
    24

    simple while loop prob driving me mad!


    Hi i wish to simply display the results of a column.. i use....

    Code:
    $query  = "SELECT * FROM leagues WHERE leagueid = 1";
    $result = mysql_query($query);
    
    while($row = mysql_fetch_array($result, MYSQL_ASSOC)) 
    {
    $leaguename = $row['leaguename'];
    $leagueid = $row['leagueid'];
    
    echo ($leaguename);
    }

    echo ($leaguename); is only showing the first result, why is it not showing the rest?!

    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    392
    Rep Power
    24
    this has got to be the most stupid question i ever asked! its my select statement causing the prob "where leagueid = 1"

    what an idiot, i need to take a break!

    Comments on this post

    • jabba_29 agrees : :)
  4. #3
  5. sleeping guru
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2003
    Location
    under the stars
    Posts
    2,444
    Rep Power
    180
    hmmmmm, there doesn't appear to be anything obviosuly wrong...

    i have to ask the question... there is more than one result in the db... yeah??

    how about trying to extract and print the data in a different way

    PHP Code:
    while($row mysql_fetch_object($result)) 
    {
    $leaguename $row->leaguename;
    $leagueid $row->leagueid;

    print 
    $leaguename;

    not sure why this would make a difference but it might be worth trying if you are sure there are more results to be printed !!!

    let us know how you get on

    RF
  6. #4
  7. sleeping guru
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2003
    Location
    under the stars
    Posts
    2,444
    Rep Power
    180
    Originally Posted by nshack31
    this has got to be the most stupid question i ever asked! its my select statement causing the prob "where leagueid = 1"

    what an idiot, i need to take a break!
    lol, glad you got it working!!!!

IMN logo majestic logo threadwatch logo seochat tools logo