I have the following code, which opens up a connection to a database and stores the results in a 2D array. However, I can only reference the items in the array as follows:
$object[2]['address']
Is there any way of accessing the array element numerically as well as via the key name, like this...
$object[2][2]
TIA
----- CODE --------
$user = "user";
$host = "localhost";
$password = "pa$$w0rd";
$database = "books";
$link = mysql_connect($host, $user, $password) or die("Could not connect: " . mysql_error());
echo "connection open<br>\n";
$conn = mysql_select_db($database) or die("Could not open database: $database");
echo("connected to " . $database . "<br>\n");
$sql = "select * from customers";
$result=mysql_query($sql)or die('died');
$num_rows = mysql_num_rows($result);
$j=0;
$x=1;
while($row=mysql_fetch_array($result)){
for($j=0;$j<$num_rows;$j++){
$name = mysql_field_name($result, $j);
$object[$x][$name]=$row[$name];
}
$x++;
}
mysql_free_result($result);
// echo "test: <". $object[2]['address'] . ">";
echo("<pre>");
print_r($object);
echo("</pre>");