I am using wysiwygPro editor and i want to be able to display the menu titles coming from the database.

This is an example layout:

$editor->links = array(
    array('title'=>'Home', 'URL'=>'/'),
    array('title'=>'About Us','URL'=>'/about/', 'children'=>array(
        array('title'=>'Company History','URL'=>'/about/history.php'),
        array('title'=>'Franchise Information','URL'=>'/about/franchise.php'),
        array('title'=>'Shareholders Information','URL'=>'/about/shareholders.php'),
    )),
    array('title'=>'Services', 'URL'=>'/services/'),
    array('title'=>'Contact Us', 'URL'=>'/contact/'),
);

So this is my SELECT query with the array. But i cant seem to get it right.

$menuQ = mysql_query("SELECT menu_id, title FROM menu ORDER BY menu_id ASC") or trigger_error("Query: $menuQ\n<br />MySQL Error: " .mysql_error());				
if(mysql_num_rows($menuQ) > 0){
    echo 'array(';
    while ($menuR = mysql_fetch_array($menuQ, MYSQL_ASSOC)) {
            //echo $menuR['title'].'<br/>';
            $mylinks[] = array('title'=>''.$menuR['title'].'', 'URL'=>'/?mid='.$menuR['menu_id'].'');            
    }
    echo ');';
    $editor->links = array($mylinks);    
}

can anyone correct me please?

thanks

$result		= mysql_query($sql);//execute query
if(mysql_num_rows($result)>0)
{
	$i=0;
	while($row=mysql_fetch_object($res))
	{	
		$data[$i]['table_id']	= $row->table_id;
		$data[$i]['title']		= $row->table_title;
		$mylinks				= $data[$i]['title'];
		$i++;
		
	}
}

Now $mylinks is an array having the values titles.
Hope this will do the work.

Comments
72 posts and still no code tags. WOW.

ok so i got it to work. this works:

$menuQ = mysql_query("SELECT menu_id, title FROM menu ORDER BY menu_id ASC") or trigger_error("Query: $menuQ\n<br />MySQL Error: " .mysql_error());               
if(mysql_num_rows($menuQ) > 0){
    while ($menuR = mysql_fetch_array($menuQ, MYSQL_ASSOC)) {
        $mylinks[] = array('title'=>''.$menuR['title'].'', 'URL'=>'/index.php?mid='.$menuR['menu_id'].'');           
    }
    $editor->links = $mylinks;
}
This article has been dead for over six months. Start a new discussion instead.