MySQL Forums
Forum List  »  Newbie

Newbie question
Posted by: Michael Thomas
Date: August 06, 2004 11:01PM

All I want to know is the sytax for "mysql_result()" and I can't find it on this site to save my life.

Also:

$sql = mysql_query("SELECT {$prefix}categories.id, {$prefix}categories.name, COUNT({$prefix}subcategories.id) AS subcategories FROM {$prefix}categories LEFT JOIN {$prefix}categories AS {$prefix}subcategories ON {$prefix}subcategories.ref = {$prefix}categories.id WHERE {$prefix}categories.ref = $c GROUP BY {$prefix}categories.id ORDER BY {$prefix}categories.name");
for ($x = 0; $x < $n_subcategories; $x++){
$subcategories[$x]["subcategories"] = mysql_result($sql, $x, "subcategories");
};

This bit of code is what I'm trying to understand...I have a general knowledge of programming but this gets too specific to mysql for me to follow it. I understand that the select statement is getting a list of all categories and the number of subcategories they have and it's then putting that into an array, but I don't get why the $x is in the mysql_result() nor do I understand LEFT JOIN with "subcategories" when "subcategories" isn't a real table it's.

If anyone could set me straight here it would be greatly appreciated.

Options: ReplyQuote


Subject
Written By
Posted
Newbie question
August 06, 2004 11:01PM
August 07, 2004 03:36AM
August 07, 2004 03:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.