sassenach Posted June 30, 2009 Share Posted June 30, 2009 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 Link to comment https://forums.phpfreaks.com/topic/164216-need-help-with-an-array/ Share on other sites More sharing options...
patrickmvi Posted June 30, 2009 Share Posted June 30, 2009 I believe all you would need to change is $editor->links = array($mylinks); to $editor->links = $mylinks; The $mylinks variable itself is an array and doesn't need to be wrapped in yet another array. Link to comment https://forums.phpfreaks.com/topic/164216-need-help-with-an-array/#findComment-866281 Share on other sites More sharing options...
sassenach Posted July 1, 2009 Author Share Posted July 1, 2009 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; } Link to comment https://forums.phpfreaks.com/topic/164216-need-help-with-an-array/#findComment-866929 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.