Thread: While Question
View Single Post
Old 01-15-2010, 07:43 PM   #8 (permalink)
delayedinsanity
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Lots of different ways, it all depends on what you want the data to look like and what you plan on doing with it. Without knowing the purpose of the query/display, only you know the best way, all we can do is provide examples of methods to use.

php Code:
function data_dump( $query ) {
    $results = mysql_query( $query );

    $data = array();

    while ( $row = mysql_fetch_assoc( $results ) )
        $data[] = $row;

    return $data;
}

VI has a point though, if ALL you are doing is directly echo'ing the data to STDOUT, there's no reason to take up resources storing it. Just echo it. If you need to perform operations on the data first, then echo it, store it in an array.
delayedinsanity is offline  
Reply With Quote