Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将MySQL数据库中的表放入下拉菜单_Php_Mysql_Cakephp - Fatal编程技术网

Php 将MySQL数据库中的表放入下拉菜单

Php 将MySQL数据库中的表放入下拉菜单,php,mysql,cakephp,Php,Mysql,Cakephp,有没有办法把MySQL数据库中的表放到下拉菜单中 Array ( [0] => Array ( [Post] => Array ( [id] => 4 [user_id] => 3 [title] => nun :) [body]

有没有办法把MySQL数据库中的表放到下拉菜单中

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
                )

        )

)

这已在堆栈溢出问题中得到解决。

您的表已经在一个数组中

将它们放入下拉菜单有什么困难

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
                )

        )

)

我假设您需要一个元素。应该非常直截了当-尝试使用代码并报告错误所在。

如果要从数据库中获取所有表,并在下拉选择列表中列出它们,则答案如下:

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

// 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>';

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

请注意,数据库名称没有被引用。

您能在这里进一步说明您的问题吗?标题、一句话的问题和代码片段似乎都是你的最新作品。。这就是我想要的我正在使用cakephp 1.3。。顺便提一下tnx!