SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Data in a while loop with rising numbers?!?

    I want to get data out in rising numbers from an query so I can use it outside the loop...

    Here is my query:
    PHP Code:
    $sql="SELECT * FROM ".$prefix."_turn_data WHERE turnid=$matchturn ORDER BY hole_no";
    $result mysql_query($sql);
    while(
    $row mysql_fetch_array($result)){
        
        
    $par $row['par'];
        

    What I want is to have it come out like this (if 3 records):
    $par1, $par2, $par3

    I need this later on in the script... Can this be done? Thanks in advance...

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Could this be an option?
    PHP Code:
    <?php
    $par 
    = array();
    while(
    $row mysql_fetch_assoc($result))
    {
        
    array_push($par$row['par']);
    }
    echo 
    $par[1];
    echo 
    $par[2];
    echo 
    $par[3];
    ....
    ....
    ....
    ....
    ....
    ....
    echo 
    $par[10];
    ?>
    What you're asking is possible, just a bit sloppy IMHO.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahhh Thanks... Did the job ;-)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •