PHP 读取数据库数组。。。

PHP 读取数据库数组。。。,第1张

假如 数据为 $value

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

foreach($temp as $v){

   $result[$v]=1

}

然后html的时候可以这样:

if($result['admin']){

   echo '<input type=checkbox />'

}

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

$con = mysql_connect('localhost', 'root', 'root')

mysql_select_db("php", $con)

$result = mysql_query("SELECT * FROM `game`") 

$data_name=array()//有修改

while($rs = mysql_fetch_assoc($result)){

    $data_name[] = $rs['name']

}

print_r($data_name)//是你要

$sql

=

"select

class

from

name

where

Id

=

1"

$res=mysql_query($sql)

$row=mysql_fetch_array($res)

mysql_free_result($res)

$arr=explode(',',$row['name'])

print_r($arr)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9988036.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-04
下一篇 2023-05-04

发表评论

登录后才能评论

评论列表(0条)

保存