PHP/SQL数组输出问题 [英] PHP/SQL array output problem

查看:73
本文介绍了PHP/SQL数组输出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

对于项目,我必须从数据库中获取以下数组

数组
(
[admin] =>数组([password] => admin [level] => 99)
[测试] =>数组([密码] =>测试[级别] => 1)
...
)

我收到的却是这样的:

数组
(
[..] =>数组([password] => [level] =>)
[0] => testmail1@mail.com [1] =>数组([密码] => 1234567 [级别] => 99)
[2] => testmail2@mail.com [3] =>数组([password] => 7654321 [level] => 55)
...
)

问题是[0] =>的外观. ,[1] =>每行等.

我的代码是以下代码

Hey,

for a project I have to fetch the following array from my DB

Array
(
[admin] => Array ( [password] => admin [level] => 99 )
[test] => Array ( [password] => test [level] => 1 )
...
)

What I''m recieving however looks like this:

Array
(
[..] => Array ( [password] => [level] => )
[0] => testmail1@mail.com [1] => Array ( [password] => 1234567 [level] => 99 )
[2] => testmail2@mail.com [3] => Array ( [password] => 7654321 [level] => 55 )
...
)

The problem is the appearance of the [0]=> , [1]=> etc in each row.

My code is the following one

$users=array ( "$email" => array("password" =>$passwd,  "level"=>$level  ) );
echo "<hr>";

            $result = @mysql_query( "select email, passwd, level from personen order by id" ) or die("Invalid query 1: " . mysql_error());
                for ($i=0; $i<@mysql_num_rows($result); $i++)

            {

                $k=@mysql_fetch_array ($result);

                $email= "$k[email]";

                $passwd="$k[passwd]";

                $level="$k[level]";

                $loginfo = array ("password"=>$passwd, "level"=>$level );
                array_push($users, $email, $loginfo );

            }
     print_r ($users); echo "<hr>";



有人知道怎么了吗?

在此先感谢



Anyone got an idea whats wrong?

Thanks in advance

推荐答案

users = array("
users=array ( "


email" => array("password" =>
email" => array("password" =>


passwd,"level" =>
passwd, "level"=>


这篇关于PHP/SQL数组输出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆