mysql_fetch_object in a class
| From: | Philipp Melab | Date: | Wed, 29 May 2002 07:08:52 +0000 |
| Subject: | mysql_fetch_object in a class | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-99638@lists.php.net to get a copy of this message | ||
I'm trying to create a server-side tree-menue. Therefore I wrote a class....
Does anybody know why it doesnt work?
there is a mysql_table named "menue" with the cols 'menue_id', 'name',
'parent_id'.
$open is a global array with entries who tell me which menue-points where
clicked.
class menue_point
{
var $menue_id;
var $name;
var $lvl;
var $open;
var $children;
function menue_point($point, $lvl)
{
global $open;
$this->menue_id = $point->menue_id;
$this->name = $point->name;
$this->lvl = $lvl;
$this->open = $open[$this->lvl];
$this->children = array();
if($this->open == $this->menue_id)
{
$child_id = $this->menue_id;
$childquery = "SELECT * FROM menue WHERE parent_id=$child_id;";
$childresult = mysql_query($childquery)or die(mysql_error());
$next_lvl = $this->lvl + 1;
while($CHILDPOINT = mysql_fetch_object($childresult));
{
$child = new menue_point($CHILDPOINT, $next_lvl);
array_push($this->children, $child);
}
}
}
}
It seems like '$CHILDPOINT' was empty, because the new point is 'born' but
all the vars in it are empty...
yours Philipp