Here's a function I wrote...feel free to use it. It will convert anything
into a 2D array.
Sample Table:
ID Name
1 Bob
2 Joe
3 Eric
4 Cody
$query="select * from sampletable";
$result=mysql_query($query);
$wholetable=ResultToArray($result,"ID");
foreach ($wholetable as $key=>$value)
{
print "$key. $value[Name]";
}
function ResultToArray ( $result , $key )
{
while ( $row = mysql_fetch_object ( $result ) )
{
foreach ( $row as $column => $data )
{
$thiskey=$row->$key;
$table[$thiskey][$column] = $data;
}
}
}
I hope this makes sense!!
Lewis
"Christian Ista" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > array(
> > array( $temp[0], $temp[1] ),
> > array( $temp[1], $temp[2] )
> > )
>
> I thinks it's not the right way.
>
> I have a query, this query can return 1,5,20, 200, ... rows, each row has
> 5 fields (or more or less).
>
> I'd like a 2 dimensions array, one line by row and each cell is a field
> content of the query.
>
> I program in a lot of language C/C++, Java, Delphi, C++Builder,
> ColdFusion, C# and I don't undersand why the PHP syntax for this kind of
> think is so complex and not clear.
>
> Bye
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php