made that for ya,
<pre>
<?
$lines = "| Office | ZZBill's Office | bo |
| Office | Bill's Office | bo |
| Store | Millcreek Supply | mcs |
| Office | Harry's Office | ho |
| Store | Sam's Discount Taxidermy | sdt |
| Shipping | East Coast Distribution Facility | ecdf |";
$lines = split("\n", $lines);
$tree = array();
for ($i=0;$i<count($lines);$i++)
{
$line = trim($lines[$i]);
$temp = split('\|', $line);
$key1 = trim($temp[1]);
$key2 = trim($temp[2]);
$key3 = trim($temp[3]);
$tree[$key1][$key2] = $key3;
}
echo '<hr>';
ksort($tree);
var_dump($tree);
echo '<hr>';
$lastplace = '';
while (list($key, $arr) = each($tree))
{
if ($lastplace != $key)
{
echo '* ' . $key . "\n";
$lastplace = $key;
}
ksort($arr);
while (list($pers, $plc) = each($arr))
echo " $pers is in <b>$plc</b>\n";
}
?>
</pre>
"Kath" <[EMAIL PROTECTED]> wrote in message
015301c13156$2c273500$[EMAIL PROTECTED]">news:015301c13156$2c273500$[EMAIL PROTECTED]...
> I have a MySQL table which stores information like this:
>
> | Type | Place Name | Place Abbrv |
>
> and lets say I have data in the table like:
>
> Example #1:
> | Office | Bill's Office | bo |
> | Store | Millcreek Supply | mcs |
> | Office | Harry's Office | ho |
> | Store | Sam's Discount Taxidermy | sdt |
> | Shipping | East Coast Distribution Facility | ecdf |
>
> What I'd like to do is be able to have PHP grab the information out of the
> database and sort like this on a webpage:
>
> Type Name #1:
> - Place Name (with hyperlink using the abbrv)
> - Place Name (with hyperlink using the abbrv)
>
> Type Name #2:
> - Place Name (with hyperlink using the abbrv)
> - Place Name (with hyperlink using the abbrv)
>
> For a better illustration, using the information from Example #1:
>
> Example #2:
>
> Office
> - Bill's Office (link using bo)
> - Harry's Office (link using ho)
>
> Store
> - Millcreek Supply (link using mcs)
> - Sam's Discount Taxidermy (link using sdt)
>
> Shipping
> - East Coast Distribution Facility (link using ecdf)
>
> So basically it has to group the common "Type" fields together and list
them
> together and make a hyperlink.
>
> What is the best way to do this? I've tried arrays, different MySQL
calls,
> voodoo, ouija boards and drinking, but nothing has gotten me what I need.
>
> btw, the information in "Type" is not a set number. There could be 2 or
200
> different "Type". (Otherwise this would be much easier and I might not
have
> a hangover from aforementioned drinking ;p )
>
> - k
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]