新手有关问题 从数据库中读取数据,然后创建相关数组,如何写

WBOY
Release: 2016-06-13 12:01:06
Original
1163 people have browsed it
MyException - 代码迷
首页
  • Web开发
  • Android
  • J2EE
  • PHP
  • Linux/Unix
  • MySql
  • C#
  • 更多...
当前位置: 代码迷 » PHP » 新手有关问题 从数据库中读取数据,然后创建相关数

新手有关问题 从数据库中读取数据,然后创建相关数组,如何写

www.MyException.Cn,网友分享于:2014-06-30   浏览:1次
新手问题 从数据库中读取数据,然后创建相关数组,怎么写
数组格式如下,怎么操作,谢谢

$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 />}
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template