SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Create array from results of query

    Im trying to create an array from the results of a query.

    the structure of the array needs to be like

    PHP Code:
    $temp = Array("title1: "=>100,"title2: "=>200); 
    I have tried using
    PHP Code:
    $apvalues $apvalues $returned_airports['airport'].'=>'.$returned_airports['xfer_total'].',';

    $temp =  Array($apvalues); 
    Im strugling to work this one out.

    Anyone.
    Chris

  2. #2
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you tell us little more about the structure if rows you fetch from the table?

  3. #3
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by earl-grey View Post
    Can you tell us little more about the structure if rows you fetch from the table?

    The code I have is
    PHP Code:
    while($returned_airports mysql_fetch_array($airports)) 
            {
                
    $airport_list $airport_list 
                
    $returned_airports['airport'] .'<br>Total transfers to date: ('.$returned_airports['xfer_total'].')''<br><br>';
    //this is the row I want in the array somehow.            
    $apvalues $apvalues $returned_airports['airport'].'=>'.$returned_airports['xfer_total'].',';
                
                
                
                
    //echo $apvalues;
            


  4. #4
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $apvalues = array();
    while(
    $returned_airports mysql_fetch_array($airports)) 
            {
                
    $airport_list $airport_list 
                
    $returned_airports['airport'] .'<br>Total transfers to date: ('.$returned_airports['xfer_total'].')''<br><br>';
    //this is the row I want in the array somehow.            
    $apvalues[$returned_airports['airport']] = $returned_airports['xfer_total'];
                
                
                
                
    //echo $apvalues;
            
    }
    print_r($apvalues); 

  5. #5
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a million for this. apreciated
    Chris


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
  •