网站建设资讯

NEWS

网站建设资讯

php选择数据库数组 php实现数据筛选

关于php获取数据库的内容存为数组的问题

php查询mysql数据库并将结果保存到数组的方法。具体分析如下:

成都创新互联公司自2013年起,是专业互联网技术服务公司,拥有项目网站建设、成都做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元宝坻做网站,已为上家服务,为宝坻各地企业和个人服务,联系电话:028-86922220

主要用到了mysql_fetch_assoc函数

mysql_fetch_assoc语法如下:

?

1

array mysql_fetch_assoc (resource $Result_Set)

范例代码如下:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

?php

$UserName = 'abc';

$Password = '1234';

$DbHandle = mysql_connect ('localhost', $UserName, $Password);

if (!$DbHandle) {

die 'No database connection could be established.';

}

$DBName = 'w3db;

if (!mysql_select_db ($DBName, $DbHandle)) {

die 'Database could not be selected.';

}

$Query = "SELECT ISBN, Title, Author FROM articles";

$articles = mysql_query ($Query, $DbHandle));

while ($Row = mysql_fetch_assoc ($articles)) {

echo "ISBN = $Row['ISBN']br /\n";

echo "Title = $Row['Title']br /\n";

echo "Author = $Row['Author']br /\n";

}

?

PHP 读取数据库数组。。。

假如 数据为 $value

$temp=explode(",",$value); 

foreach($temp as $v){

$result[$v]=1;

}

然后html的时候可以这样:

if($result['admin']){

echo 'input type=checkbox /';

}

同理其他类型,可以foreach 输出

PHP 在数据库筛选出几个数组后在把他们放到一个数组里

不知道你想要做什么?数组$data就是可能包含这三种信息的一个数组,

你将他们根据条件,将数组分别赋值给了变量,再转换成一个数组?

是不是为了调去方便为了修改下键值?

如果是这样的话,你可以这样写

$new = array('baidu' = $baiduurl, '360' = $sanurl, 'tengxun' = $weiyunurl );

然后使用 $new['baidu']、$new['360']、$new['tengxun']分别访问

php 数组选择

?php

$a=array(0=array('type'=1,'title'='hehe'),1=array('type'=2,'title'='haha'),2=array('type'=1,'title'='gaha'));

$arr=array();

for($i=0;$icount($a);$i++){

if($a[$i]['type']==1){

$arr[]=$a[$i];

}

}

?

这样就可以得到你说的数组了??


本文题目:php选择数据库数组 php实现数据筛选
网站URL:http://cdweb.net/article/ddchdoi.html