hi sid, thanks for the reply. I didn't get any error, it just returns nothing when it is suppose to return a list box. I think this is a valid php:
function returnDCatDropDown($name='dCat_{counter}',$initialselect=0)
the whole php is in one line, it just got cut off while pasting here 🙂 there's nothing wrong with right? (i hope)
Now this is the part that confuses me.
this is the return drop down function:
function returnDCatDropDown($name='dCat_{counter}',$initialselect=0)
{
global $siteDB;
static $ran, $dropDown;
if (!$ran)
{
$dropDown .= "<select name=$name id=$name>";
$dropDown .= "<option value=\"0\">Main Category</option>";
$siteDB->query('SELECT id, name FROM ' .DB_PREFIX. '_download_cat;');
while ($array = mysql_fetch_row($siteDB->results))
{
$dropDown .= "<option value=\"$array[0]\">$array[1]</option>";
}
$dropDown .= '</select>'; // dropdown created, can begin changing selected option
$ran=TRUE;
if ($initialselect !=0)
{
$newDropDown= str_replace('value="'.$initialselect.'"','value="'.$initialselect.'"'.' selected="selected"', $dropDown);
return $newDropDown; // modified, selected option
}
else
return $dropDown; // unmodified
}
else
{
if ($initialselect !=0)
{
$newDropDown= str_replace('value="'.$initialselect.'"','value="'.$initialselect.'"'.' selected="selected"', $dropDown);
return $newDropDown; // modified, selected option
}
else
return $dropDown; // unmodified
}
}
and this is the code that calls the function:
$dropdown=returnDCatDropDown();
$siteDB->query('SELECT id, name, parent FROM ' .DB_PREFIX. '_download_cat;');
while ($array = mysql_fetch_row($siteDB->results))
{
$dropdown=returnDCatDropDown('parent_id_{counter}',$array[2]);
$newModifyForm= str_replace('{counter}',$array[0],$modifyForm); // replace with cat_id
$newModifyForm= str_replace('{catDropDown}',$dropdown,$newModifyForm); // replace with parent_id
$newModifyForm= str_replace('{value}',$array[1],$newModifyForm); // replace with cat name
print $newModifyForm;
}
notice the first line?: $dropdown=returnDCatDropDown(); Without the line in bold, the script returns nothing, but with the line, it works fine (drop down list returned). I am EXTREMELY confused 😕 can you shed some light on this?