Hi!
Here's my problem:
I'm trying to query MySQL to get a list of links divided into categories. Here's my query:
$query = mysql_query("SELECT links.link_name, links.url, links.category_id_r,
categories.category_id, categories.category_name, categories.portal_id_r, portals.portal_id,
portals.user_id_r FROM categories, portals, links WHERE portals.user_id_r=1 AND
portals.portal_id=categories.portal_id_r AND categories.category_id=links.category_id_r");
I want to get 1 category and then get all the links that belong to this category, then the next category etc.
Here's how I'm TRYING to do that with foreach:
while ($sql = mysql_fetch_array($query)) {
$cat_name = $sql["category_name"];
echo("$cat_name: ");
foreach ($sql as $link_name) {
$url = $sql["category_name"];
echo("<A href=$url>$link_name</A> . ");
if ($sql["category_id"] == $sql "category_id_r"]) {
}
}
echo ("<P>");
}
But...it doesn't work...I've tried other cominations with the same result...what am I doing wrong? Any help would be...nice!
Best regards,
Simon