$foo = array();
while($row = mysql_fetch_assoc($result)) {
$foo[] = $row;
}
Alternatively, array_push($foo, $row); would also work.
On 11/03/2011, at 5:55 PM, Michael Adams wrote:
> Is there a simple way to do this so my whole weekend isn't spoiled worrying
> about it.
>
> I want to take all the data from a MySQL query and drop it into another table.
>
> I tried:
> ****
> $foo = array( );
> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
> $foo -> append($row);
> }
> ****
>
> But that was a PHP5 solution and even on PHP5 did not seem to like appending
> the first result to an empty array.
>
> This is the best i can do at present which would be extremely wasteful if i
> had 20 columns in the table instead of the three i am showing here:
> ****
> $foo = array( );
> $i = 1;
> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
> $foo[i] = array ('tagID' => $row['id'],
> 'date' => date("d-m-Y H:i",strtotime
> ($row['load_date'])),
> 'keyword' => htmlspecialchars($row['keywords'])) ;
> i++;
> }
> ****
>
> TIA
>
> --
> Michael
>
> --
> NZ PHP Users Group: http://groups.google.com/group/nzphpug
> To post, send email to [email protected]
> To unsubscribe, send email to
> [email protected]
---
Simon Welsh
Admin of http://simon.geek.nz/
Who said Microsoft never created a bug-free program? The blue screen never,
ever crashes!
http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]