来自数据库PHP的数组 [英] Array from Database PHP

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

问题描述

我需要从数据库创建一个数组;myTable看起来像这样

Hi I need to create an array from database; myTable looks like this

id           | name       | address |
-------------+------------+---------------
1            | Peter      | Union Streeet|
2            | John       | King Street  | 

然后我有sql,它将从数据库中选择值

Then I have sql that will select values from database

$record=mysql_query("SELECT * FROM myTable");
while($row=mysql_fetch_assoc($record)){
      //fill array how to fill array that will look like bellow from database???
}

我需要创建一个看起来像这样的数组

I need to create array that will look like this

$list = array (
    array('$row[id]', '$row[name]', '$row[address]'),
    // array('$row[id]', '$row[name]', '$row[address]')
    // FOR EACH LINE FROM DATABASE NEW NESTED ARRAY
);

推荐答案

$record=mysql_query("SELECT * FROM myTable");
$list = array();
while($row=mysql_fetch_assoc($record)){
      //fill array how to fill array that will look like bellow from database???
    $list[] = row;
}

这篇关于来自数据库PHP的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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