Results 1 to 2 of 2

Thread: how to placed the query results to an associative array?

  1. #1

    Thread Starter
    Member blueorange's Avatar
    Join Date
    Sep 2008
    Location
    Philippines
    Posts
    47

    Exclamation how to placed the query results to an associative array?

    I want to have a page with next and previous link as well as the pagination of the pages like 1 2 3 4. How do i placed the results of the query to an array without appending a LIMIT statement to the SQL. What i mean is another method that uses array to display records with pagination. My sql query is so complex that it needs to store the ids to an array. thanks.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: how to placed the query results to an associative array?

    I don't think that your SQL is so complex that it would need to store all of the results in an array. that would be slow and inefficient, anyway; if you happen to have a large database, this will take forever.

    post your code instead!

    however, if you really want what you were asking for:
    PHP Code:
    $myarray = array();
    $query mysql_query($sql);
    while(
    $array mysql_fetch_assoc($query)){
      
    $myarray[$array['id']] = $array;
    }

    print_r($myarray); 

Posting Permissions

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



Click Here to Expand Forum to Full Width