While surfing the net I found this forum and thought I would join in on the fun so howdy world 😃 I am totally a NooB in PhP and am having a particular issue with a function I am attempting to create and call upon failing out. I am not sure what is wrong with the code but thought maybe some of ya'll may be of assistance. I will break down what the code is "suppose" to do below but being a NooB I am sure I have something wrong with the code because it just fails once I call upon it 😕 Thanks for the help and look forward to being a part of the forum.
Added Die Statement Where It Fails (The Line Just Below Die Statement)
function categoryFeatures($category_id) {
global $db, $tables;
$sub_cat_list = array ();
$feat_ad_random = array ();
$sub_cat_query = $db->Execute("SELECT `ID` FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = ".$db->qstr($category_id)." ORDER BY `ASC`");
$sub_cat_find = mysql_fetch_array($sub_cat_query);
while (!$sub_cat_find->EOF)
{
$feat_ad_query = $db->Execute("SELECT * FROM `{$tables['link']['name']}` WHERE `CATEGORY_ID` = ".$db->qstr($sub_cat_find)." AND `STATUS` = '2' AND `FEATURED` = '1' ORDER BY RAND()");
if (mysql_num_rows($feat_ad_query)) {
while ($ftr_lst = mysql_fetch_array($feat_ad_query))
{
$feat_ad_random += categoryFeatures($ftr_lst['ID']);
}
}
echo "Test Fail";
die();
$sub_cat_list = array_merge($sub_cat_list, categoryFeatures($sub_cat_find['ID']));
$sub_cat_query->MoveNext();
}
return $feat_ad_random;
}
Theoretically the code should do two things. One it should gather info from a db relating to a category id (find all cats with parent ids as the current cat id). Then it should call upon another table trying to find rows with matching category ids as those found from the first while statement. Then it just repeats the process until all children cats and their listings have been found. Any assistance would greatly be appreciative. Wll continue trying to figure it out and will update the code as I attempt other solutions.