| | |
need help with an array
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2009
Posts: 42
Reputation:
Solved Threads: 0
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:
So this is my SELECT query with the array. But i cant seem to get it right.
can anyone correct me please?
thanks
This is an example layout:
PHP Syntax (Toggle Plain Text)
$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.
PHP Syntax (Toggle Plain Text)
$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
php Syntax (Toggle Plain Text)
$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++; } }
Hope this will do the work.
Last edited by peter_budo; Jul 1st, 2009 at 1:03 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
We only have to do a very few things right in our life, so long as we don't do too many things wrong.
•
•
Join Date: Mar 2009
Posts: 42
Reputation:
Solved Threads: 0
ok so i got it to work. this works:
PHP Syntax (Toggle Plain Text)
$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; }
![]() |
Similar Threads
- Can I ghost a RAID array??? (Windows NT / 2000 / XP)
- Creating dynamic array structures (C++)
- Array limit (C)
- struct dynamic 2d array alloc (C)
- string to integer array transformation (C)
- Array (Visual Basic 4 / 5 / 6)
Other Threads in the PHP Forum
- Previous Thread: Automatically add a link & new page
- Next Thread: Upload File In Server
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess 301 access ajax apache api array beginner binary broken cakephp checkbox class cms code compression cron curl database date directory display download dropdown dynamic echo email error file files folder form forms function functions google href htaccess html httppost image include insert integration ip java javascript joomla limit link login loop mail md5 menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search secure select server sessions sms soap source space speed sql structure syntax system table tutorial update upload url validation validator variable video votedown web xml youtube






