i am doing this in the editor
<?php
include "scripts/connect_to_mysql.php";
$sql2= mysql_query("SELECT fruit.parent, fruit.lft, fruit.rgt
FROM fruit AS node,
fruit AS parent1 WHERE node.lft BETWEEN parent1.lft AND parent1.rgt
AND node.parent = 'Banana'
ORDER BY parent1.lft;");
$categoryCount = mysql_num_rows($sql2);
if ($categoryCount>0 )
{
while($row2 = mysql_fetch_array($sql2))
{
$name= $row2["node.parent"];
}
echo '<div>'.$name.'</div>';
}
?>
Before getting to the while loop there is a error in mysql_num_rows it seems like the SQL statement is supplying a none valid argument as the error says. hopefully there is a mistake int he statement I am not able to see it yet.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home3/nyhungry/public_html/parent/cacofamily.php on line 10
Table structure is identical
--
-- Table structure for table `fruit`
--
CREATE TABLE IF NOT EXISTS `fruit` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent` varchar(255) NOT NULL,
`title` varchar(255) NOT NULL,
`lft` int(11) NOT NULL,
`rgt` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;
--
-- Dumping data for table `fruit`
--
INSERT INTO `fruit` (`id`, `parent`, `title`, `lft`, `rgt`) VALUES
(1, '', 'Food', 1, 18),
(2, 'Food', 'Fruit', 2, 11),
(3, 'Fruit', 'Red', 3, 6),
(4, 'Red', 'Cherry', 4, 5),
(5, 'Fruit', 'Yellow', 7, 10),
(6, 'Yellow', 'Banana', 8, 9),
(7, 'Food', 'Meat', 12, 17),
(8, 'Meat', 'Beef', 13, 14),
(9, 'Meat', 'Pork', 15, 16);
Please can you take a look at the statement?