概述
<html>
<head> <meta http-equiv=content-type content="text/html; charset=GBK">
<title>planar array insert into db </title>
</head>
<body>
<?php
include('/home/xiaocong#######');
$myconn=mysql_connect("####","###","###");
mysql_select_db("####_bi",$myconn);
$process=array();
echo $process[0];
echo $process[1];
echo "<br>";
$source_file="#########l".$filename; //文件地址
if(!$source_file)
{
echo'文件不存在';
}
else
{
unlink($source_file);
}
$file_pointer = fopen($source_file, "a"); //参数 a 追加 w 新写入
//$country=array('lid_50001'=>array('uid'=>'root', 'class'=>1,'value'=>'中国'),
//'lid_53297'=>array('uid'=>'root', 'class'=>1,'value'=>'泰国'));
for(reset($country);$key=key($country);next($country))
{
echo "key=" . $key;
echo "<br>";
$lid=$country[$key];
while(list($uid,$value)=each($lid))
{
echo $uid . ":";
echo $value;
echo "<br>";
array_push($process,$value);
}
echo "class:" . $process[1] . "value:" . $process[2] . "<br>";
$temp_str=substr($key,-5);
$insertDB="insert into t_qeesoo_CPD (Cuid,class,Cvalue) values('$temp_str','$process[1]','$process[2]')";
echo $insertDB;
mysql_query($insertDB);
fwrite($file_pointer, $insertDB);
fwrite($file_pointer, ";/n");
$process=array();
// mysql_query("source /home/xiaocong/public_html/planar_array.sql");
echo "<br>";
}
//echo count($country);
echo "<br>";
//$province = array(
//'lid_50002'=>array('uid'=>'50001', 'class'=>2,'value'=>'山东省'),
//'lid_50160'=>array('uid'=>'50001', 'class'=>2,'value'=>'江西省'));
$process=array();
for(reset($province);$key=key($province);next($province))
{
echo "key=" . $key;
echo "<br>";
$lid=$province[$key];
while(list($uid,$value)=each($lid))
{
echo $uid . ":";
echo $value;
echo "<br>";
array_push($process,$value);
}
echo "class:" . $process[1] . "value:" . $process[2] . "<br>";
$temp_str=substr($key,-5);
$insertDB_2="insert into t_qeesoo_CPD (Cuid,Puid,class,Pvalue) values('$process[0]','$temp_str','$process[1]','$process[2]')";
// echo $insertDB;
fwrite($file_pointer, $insertDB_2);
fwrite($file_pointer, ";/n");
$process=array();
echo "<br>";
}
//fwrite($file_pointer, "*************************************");
//$city = array(
//'lid_50003'=>array('uid'=>'50002', 'class'=>3,'value'=>'济南','citycode'=>'0531'),
//'lid_50014'=>array('uid'=>'50002', 'class'=>3,'value'=>'青岛','citycode'=>'0532'));
$process=array();
for(reset($city);$key=key($city);next($city))
{
echo "key=" . $key;
echo "<br>";
$lid=$city[$key];
while(list($uid,$value)=each($lid))
{
echo $uid . ":";
echo $value;
echo "<br>";
array_push($process,$value);
}
echo "class:" . $process[1] . "value:" . $process[2] . "<br>";
$temp_str=substr($key,-5);
$insertDB_3="insert into t_qeesoo_CPD (Puid,Cityuid,class,Cityvalue) values('$process[0]','$temp_str','$process[1]','$process[2]')";
// echo $insertDB;
fwrite($file_pointer, $insertDB_3);
fwrite($file_pointer, ";/n");
$process=array();
echo "<br>";
}
//$district = array(
//'lid_50004'=>array('uid'=>'50003', 'class'=>4,'value'=>'历下区'),
//'lid_50005'=>array('uid'=>'50003', 'class'=>4,'value'=>'市中区'));
$process=array();
for(reset($district);$key=key($district);next($district))
{
echo "key=" . $key;
echo "<br>";
$lid=$district[$key];
while(list($uid,$value)=each($lid))
{
echo $uid . ":";
echo $value;
echo "<br>";
array_push($process,$value);
}
echo "class:" . $process[1] . "value:" . $process[2] . "<br>";
$temp_str=substr($key,-5);
$insertDB_4="insert into t_qeesoo_CPD (Cityuid,Duid,class,Dvalue) values('$process[0]','$temp_str','$process[1]','$process[2]')";
// echo $insertDB;
fwrite($file_pointer, $insertDB_4);
fwrite($file_pointer, ";/n");
$process=array();
echo "<br>";
}
/*
$query="select * from t_qeesoo_visitdata limit 0,10";
$result=mysql_query($query);
while($row=mysql_fetch_array($result))//通过循环读取数据内容
{
?>
<tr>
<td align="center" height="19"><?echo $row["id"]?></td>
<td align="center"><?echo $row["guid"]?></td>
<td align="center"><?echo $row["src_ip"]?></td>
<td align="center"><?echo $row["src_href"]?></td>
<td align="center"><?echo $row["referrer"]?></td>
<td align="center"><?echo $row["start_time"]?></td>
<td align="center"><?echo $row["type"]?></td>
<td align="center"><?echo $row["state"]?></td>
</tr>
<?php
}
*/
//关闭对数据库的连接
mysql_close($myconn);
?>
</body>
</html>
最后
以上就是自由流沙为你收集整理的php 二维数组入mysql 数据库的全部内容,希望文章能够帮你解决php 二维数组入mysql 数据库所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复