View Single Post
Join Date: Dec 2008
Posts: 94
Reputation: sikka_varun is an unknown quantity at this point 
Solved Threads: 11
sikka_varun's Avatar
sikka_varun sikka_varun is offline Offline
Junior Poster in Training

Re: Category hierarchy problem............

 
0
  #2
Dec 2nd, 2008
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..

  1. //mysql connection
  2.  
  3.  
  4. $objcatId = new catId();
  5. $rsId[] = explode(",",$objcatId->prod_view(22));
  6. print_r($rsId);
  7.  
  8. class catId{
  9.  
  10. static $idvalues="";
  11.  
  12. function prod_view($id)
  13. {
  14.  
  15. $sql = mysql_query("select id from cart_category where pid='$id'") or die(mysql_error());
  16. $num = mysql_num_rows($sql);
  17.  
  18. if($num > 0)
  19. {
  20.  
  21. while($row = mysql_fetch_array($sql))
  22. {
  23. if(self::$idvalues=="")
  24. {
  25. self::$idvalues=$row['id'];
  26. }
  27. else
  28. {
  29. self::$idvalues.=",".$row['id'];
  30. }
  31.  
  32. $this->prod_view($row['id']);
  33.  
  34. }
  35.  
  36. }
  37.  
  38. return self::$idvalues;
  39. }
  40.  
  41. }


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..
VâRûN
---Happy to Help---
sikka_varun@yahoo.com
Reply With Quote