晚上做的一点东西,发出来大家共享下!
Code
<?php
//php 链接数据库
mysql_connect("localhost", "root", "hicc") or die("Could not connect: " . mysql_error());
mysql_select_db("babyker");
$result = mysql_query("select messageid,albumid,uid from uch_messageid");
$hbarr = array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
array_push($hbarr, $row);
}
//根据mid 获取用户id和相册aid
$getresultbymid = array();
foreach($hbarr as $item){
$getresultbymid[$item['messageid']] = $item['uid'] . ',' . $item['albumid'];
}
//根据uid 获取用户mid和相册aid
$getresultbyuid = array();
foreach($hbarr as $item){
$getresultbyuid[$item['uid']] = $item['messageid'] . ',' . $item['albumid'];
}
//根据aid 获取用户mid和相册uid
$getresultbyaid = array();
foreach($hbarr as $item){
$getresultbyaid[$item['albumid']] = $item['messageid'] . ',' . $item['uid'];
}
//根据mid 获取用户id和相册aid 写入 common_getresultbymid
$mid = var_export ($getresultbymid, true);
file_put_contents('common_getresultbymid.php',"<?php \$getresultbymid = $mid;?>");
//根据uid 获取用户id和相册aid 写入 common_getresultbyuid
$uid = var_export ($getresultbyuid, true);
file_put_contents('common_getresultbyuid.php',"<?php \$getresultbyuid = $uid;?>");
//根据aid 获取用户id和相册aid 写入 common_getresultbyaid
$aid = var_export ($getresultbyaid, true);
file_put_contents('common_getresultbyaid.php',"<?php \$getresultbyaid = $aid;?>");
exit();
?>
<?php
//php 链接数据库
mysql_connect("localhost", "root", "hicc") or die("Could not connect: " . mysql_error());
mysql_select_db("babyker");
$result = mysql_query("select messageid,albumid,uid from uch_messageid");
$hbarr = array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
array_push($hbarr, $row);
}
//根据mid 获取用户id和相册aid
$getresultbymid = array();
foreach($hbarr as $item){
$getresultbymid[$item['messageid']] = $item['uid'] . ',' . $item['albumid'];
}
//根据uid 获取用户mid和相册aid
$getresultbyuid = array();
foreach($hbarr as $item){
$getresultbyuid[$item['uid']] = $item['messageid'] . ',' . $item['albumid'];
}
//根据aid 获取用户mid和相册uid
$getresultbyaid = array();
foreach($hbarr as $item){
$getresultbyaid[$item['albumid']] = $item['messageid'] . ',' . $item['uid'];
}
//根据mid 获取用户id和相册aid 写入 common_getresultbymid
$mid = var_export ($getresultbymid, true);
file_put_contents('common_getresultbymid.php',"<?php \$getresultbymid = $mid;?>");
//根据uid 获取用户id和相册aid 写入 common_getresultbyuid
$uid = var_export ($getresultbyuid, true);
file_put_contents('common_getresultbyuid.php',"<?php \$getresultbyuid = $uid;?>");
//根据aid 获取用户id和相册aid 写入 common_getresultbyaid
$aid = var_export ($getresultbyaid, true);
file_put_contents('common_getresultbyaid.php',"<?php \$getresultbyaid = $aid;?>");
exit();
?>