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.


$sql = mysql_query("SELECT {$prefix}, {$prefix}, COUNT({$prefix} AS subcategories FROM {$prefix}categories LEFT JOIN {$prefix}categories AS {$prefix}subcategories ON {$prefix}subcategories.ref = {$prefix} WHERE {$prefix}categories.ref = $c GROUP BY {$prefix} ORDER BY {$prefix}");
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

Written By
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.