RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
php读取数据库里的数组 php读取数组元素

PHP怎么从数据库中取出一维数组

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

成都创新互联是一家以成都网站建设公司、网页设计、品牌设计、软件运维、网站推广、小程序App开发等移动开发为一体互联网公司。已累计为石雕等众行业中小客户提供优质的互联网建站和软件开发服务。

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);//是你要的

PHP 读取数据库数组。。。

假如 数据为 $value

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

foreach($temp as $v){

$result[$v]=1;

}

然后html的时候可以这样:

if($result['admin']){

echo 'input type=checkbox /';

}

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

PHP 去读数据库到数组 怎么弄

本文实例讲述了php实现通用的从数据库表读取数据到数组的函数。分享给大家供大家参考。具体分析如下:

此函数不关心表结构,只需要指定表名、结构和查询条件既可以对表进行通用查询操作,非常实用。

function listmytablerows($table, $name, $field, $where, $textID) { / / Connect to the database and query execution connect (); $Sql = "select * from". $table. "". $where. "ORDER BY". $field; $Req = mysql_query($sql); $Res = mysql_num_rows($req); ? Select name = "?php echo $name; ?" id="?php echo $textID; ?" option value="" ____/ option ? Php / / We do a loop that will read the information for each record while ($data = mysql_fetch_array($res)) { / / We display the information from the current record ? Option value = "?php echo $data['id']; ?" ?php echo $data[$field]; ? / Option ? Php } ? / Select ? Php } ?


分享文章:php读取数据库里的数组 php读取数组元素
文章路径:http://cqwzjz.cn/article/doppsdi.html