help! :)>

I'm trying to return a list of links under associated categories from a
database table that has the fields: "linkID, category, name, url".

I'm selecting the fields and then trying to construct a multi-dimensional
array so that the correct items get put into it (and then printed out):

//connect to database, get results.
$link_id = mysql_connect($host, $usr, $pass) or die (mysql_error());
mysql_select_db($database, $link_id);
$sql="select category, name, url from links";
$result = mysql_query($sql, $link_id) or die ("no results");

//buil multi-dimensional array where $category[$name[$url]]

while($row=mysql_fetch_array($result)) //read a row into array
    {
    extract($row); //populate $category, $name, $url variables
    $links = array($category => array($name, $url)); //build multi-D array.
    }

// print list of categories with local anchors
// and under each category print link name and url
        
while (list($category) = each($links))
    {
    echo ("<a href=\"$PHP_SELF?#$category\">$category</font></a>");
                
        while (list($name, $url) = each ($links[$category]))
        {
        echo ("<a href=\"$url\">$name</a>");
        }
    }

right now this is only printing ONE category, and numerical index values
that contain $name and $url at the same level.

thanks for ANY suggestions!
cheers,
andrew


-- 
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]

Reply via email to