-1

Is there any way where I can put the tables in a MySQL database into a dropdown menu?

Array
(
    [0] => Array
        (
            [Post] => Array
                (
                    [id] => 4
                    [user_id] => 3
                    [title] => nun :)
                    [body] => goodmorning

sa


inyu
                    [created] => 2011-10-18 01:45:08
                    [modified] => 2011-10-18 21:15:41
                )

            [User] => Array
                (
                    [id] => 3
                    [username] => von
                    [password] => 8c1285276260289a5cfc499e233c277fdbd6098b
                    [active] => 1
                )

        )

)

This has been solved in Stack Overflow question Creating 'select' listboxes using FormHelper in CakePHP.

Community
  • 1
  • 1
MuntingInsekto
  • 1,543
  • 4
  • 19
  • 36
  • Could you expand on your question here? The title, single sentence question and code snippet seem quite unrelated – Phil Oct 18 '11 at 04:32

2 Answers2

0

You have your tables in an array already.

What is the difficulty you're having putting them into a drop-down menu?

I assume that you are want a <select> element. Should be fairly straight-forward - have a go and report back with the code you tried to use and what went wrong.

thomasrutter
  • 114,488
  • 30
  • 148
  • 167
0

If you want to fetch all tables from your database, and list them in a drop down select list, then here is the answer:

/*****************/

// Database connection here

$table_list = mysql_query("SHOW TABLES FROM Your_DataBase_Name");
$dropDown = '<select>';
while( $row = mysql_fetch_row($table_list))
{
    $dropDown .= '<option value="' . $row[0] . '">' . $row[0] . '</option>';
}

$dropDown .='</select>';

/*********************************/

Please note that the database name is not quoted.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
CoreCoder
  • 389
  • 1
  • 4
  • 14