RE: [PHP-DB] Sorting multidimensional arrays from mysql
| From: | Juffermans, Jos | Date: | Mon, 02 May 2005 13:50:51 +0000 |
| Subject: | RE: [PHP-DB] Sorting multidimensional arrays from mysql | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-39338@lists.php.net to get a copy of this message | ||
mysql_fetch_array will always only return 1 row. $array['town'] won't be an
array but just a text and is therefor interpreted differently.
If you can give us more information (ie data model, output sample) we might
be able to help you a bit better.
Jos
-----Original Message-----
From: J. Connolly [mailto:web@jozef.info]
Sent: 02 May 2005 15:42
To: PHP list
Subject: [PHP-DB] Sorting multidimensional arrays from mysql
Morning all,
I am having problems understanding what I need to do. Usually for most
of my work, all i need to do is pull the information and place it like this:
function office_list(){
global $link;
echo "<table><tr>";
$sql = "SELECT town
FROM offices";
$result = mysql_query($sql, $link);
while ($array = mysql_fetch_array($result)){
$office = $array['town'];
$state = $array['state'];
$zip = $array['zip'];
echo "<td>$office</td>
<td>$state</td>
<td>$zip</td>";
}
echo "</tr></table>";
}
But now I need to separate the information in order to build a more
complex table. I do not understand how to obtain each cell. I have a
fixed number so it will never change.
I thought multidimensional arrays came as array[0][0], but when i try
$office = $array['town'][0]
I just get the first letter of that office. If someone could point me in
the right direction I'd greatly appreciate it. I think I just do not
know the terminology I am looking for. The PHP manual keeps brining me
to pages that are not what I need.
Thank you,
jozef
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php