Hii...
What it seems from your code is, you are storing the value after mysql_fetch_array in an array without an id..
So try this code..
//mysql connection
$objcatId = new catId();
$rsId[] = explode(",",$objcatId->prod_view(22));
print_r($rsId);
class catId{
static $idvalues="";
function prod_view($id)
{
$sql = mysql_query("select id from cart_category where pid='$id'") or die(mysql_error());
$num = mysql_num_rows($sql);
if($num > 0)
{
while($row = mysql_fetch_array($sql))
{
if(self::$idvalues=="")
{
self::$idvalues=$row['id'];
}
else
{
self::$idvalues.=",".$row['id'];
}
$this->prod_view($row['id']);
}
}
return self::$idvalues;
}
}
Try this code... The system im using right now doesnt have PHP installed.. so cant check it here.. Hope this helps you.. If any problem comes, then tell me the error..
Reputation Points: 11
Solved Threads: 12
Junior Poster in Training
Offline 94 posts
since Dec 2008