<pre name="code" class="php">$params=array(
"tid"=>"3",
"fid"=>"36",
"uname"=>"tom",
"title"=>"性感美女老师,高清图",
"uid"=>"5",
"times"=>"1412563750",
"pid"=>"6",
"first"=>"1",
"content"=>"性感美女老师,高清图(3P)",
"fjStatus"=>"2",
"position"=>"1",
"len"=>"52",
"threadImgUrl"=>"201410/06/mccabcd1.jpg",
"attachments"=>[
array(
"aid"=>"6",
"tableId"=>"1",
"filename"=>"1.jpg",
"size"=>"62910",
"saveUrl"=>"201410/06/mccabcd1.jpg",
"width"=>"500"
),
array(
"aid"=>"7",
"tableId"=>"1",
"filename"=>"2.jpg",
"size"=>"62910",
"saveUrl"=>"201410/06/mccabcd2.jpg",
"width"=>"500"
),
array(
"aid"=>"8",
"tableId"=>"1",
"filename"=>"3.jpg",
"size"=>"62910",
"saveUrl"=>"201410/06/mccabcd3.jpg",
"width"=>"500"
),
array(
"aid"=>"9",
"tableId"=>"1",
"filename"=>"4.jpg",
"size"=>"62910",
"saveUrl"=>"201410/06/mccabcd4.jpg",
"width"=>"500"
)]);
循环调用:
<pre name="code" class="php">if(count($params["attachments"])>0)
{
foreach ($params["attachments"] as $fujian)
{
$aid=$fujian["aid"];
$tableId=$fujian["tableId"];
$filename=$fujian["filename"];
$size=$fujian["size"];
$saveUrl=$fujian["saveUrl"];
$width=$fujian["width"];
/*
// // 附件表
$query="";
$query=sprintf("insert into pre_forum_attachment(aid,tid,pid,uid,tableid) VALUES('%s','%s','%s','%s',9)"
,mysql_real_escape_string($aid)
,mysql_real_escape_string($tid)
,mysql_real_escape_string($pid)
,mysql_real_escape_string($uid));
mysql_query($query) or die(mysql_error());
// // 附件表2
$query="";
$query=sprintf("insert into pre_forum_attachment_1(aid,tid,pid,uid,dateline,filename,filesize,attachment,isimage,width)"
."VALUES('%s','%s','%s','%s','%s','%s','%s','%s',1,'%s')"
,mysql_real_escape_string($aid)
,mysql_real_escape_string($tid)
,mysql_real_escape_string($pid)
,mysql_real_escape_string($uid)
,mysql_real_escape_string($times)
,mysql_real_escape_string($filename)
,mysql_real_escape_string($size)
,mysql_real_escape_string($saveUrl)
,mysql_real_escape_string($width));
mysql_query($query) or die(mysql_error());
}
}