新手问题 从数据库中读取数据,然后创建相关数组,怎么写
数组格式如下,怎么操作,谢谢
$data=array(
0=>array('id'=>1001,'password'=>'123456'),
1=>array('id'=>1002,'password'=>'78956'),
2=>array('id'=>1003,'password'=>'7886'),
);
下面是我写的,不行,该怎么写,感谢
$i=1;
$data=array(
$sql="select * from us1 ";
$conn=mysql_query($sql,$connec);
while($rs=mysql_fetch_array($conn))
{
$i=>array('id'=>$rs[id],'password'=>$rs[password]),
$i=$i+1;
}
);
------解决思路----------------------$sql="select * from us1 ";<br />$conn=mysql_query($sql,$connec);<br />while($rs=mysql_fetch_array($conn))<br />{ <br /> $data[] = array('id'=>$rs[id],'password'=>'固定内容123456'),<br />}
登录后复制