帝国cms图片增加一个含图片及标题字段像morepic
第一步:增加一个字段yspic
字段增加重要步骤请看图片:
在输入表单中复制下面的代码:
<script>
function domvadd_yspic()
{
var i;
var str='';
var oldi=0;
var j=0;
var addnum=0;
addnum=parseInt(document.add.mvaddnum_yspic.value);
oldi=parseInt(document.add.mveditnum_yspic.value);
for(i=1;i<=addnum;i++)
{
j=i+oldi;
str=str+'<tr><td align="center"><input type="text" name="yspic_1[]" id="yspic_1_'+j+'" value=""><a onclick="window.open(\'ecmseditor/FileMain.php?type=1&classid=<?=$classid?>&infoid=<?=$id?>&doing=1&field=yspic_1_'+j+'\',\'\',\'width=700,height=550,scrollbars=yes\');" title="选择已上传的图片"><img src="../data/images/changeimg.gif" border="0" align="absbottom"></td><td align="center"><input type="text" name="yspic_2[]" id="yspic_2_'+j+'" value=""></td></tr>';
}
document.getElementById("mvadd_yspic").innerHTML="<table width='100%' border=0 cellspacing=1 cellpadding=3>"+str+"</table>";
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5">
<tr><td align="center">图片地址</td><td align="center">图片说明</td></tr>
</table>
</td>
</tr>
<tr>
<td>
<?php
if($ecmsfirstpost==1)
{
?>
<table width='100%' border=0 cellspacing=1 cellpadding=3>
<?php
$editnum=3;
for($i=1;$i<=$editnum;$i++)
{
?>
<tr><td align="center"><input type="text" name="yspic_1[]" id="yspic_1_<?=$i?>" value=""><a onclick="window.open('ecmseditor/FileMain.php?type=1&classid=<?=$classid?>&infoid=<?=$id?>&doing=1&field=yspic_1_<?=$i?>','','width=700,height=550,scrollbars=yes');" title="选择已上传的图片"><img src="../data/images/changeimg.gif" border="0" align="absbottom"></a></td><td align="center"><input type="text" name="yspic_2[]" id="yspic_2_<?=$i?>" value=""></td></tr>
<?php
}
?>
</table>
<?php
}
else
{
$editnum=0;
if($r['yspic'])
{
$r['yspic']=stripSlashes($r['yspic']);
?>
<table width='100%' border=0 cellspacing=1 cellpadding=3>
<?php
//录入项
$j=0;
$mvf_record=explode('||||||',$r['yspic']);
$mvf_count=count($mvf_record);
for($i=0;$i<$mvf_count;$i++)
{
$j=$i+1;
$mvf_field=explode("::::::",$mvf_record[$i]);
?>
<tr><td align="center"><input type="text" name="yspic_1[]" id="yspic_1_<?=$j?>" value="<?=$mvf_field[0]?>"> <input type="hidden" name="yspic_mvid[]" id="yspic_mvid_<?=$j?>" value="<?=$j?>"><input type="checkbox" name="yspic_mvdelid[]" id="yspic_mvdelid_<?=$j?>" value="<?=$j?>">删</td><td align="center"><input type="text" name="yspic_2[]" id="yspic_2_<?=$j?>" value="<?=$mvf_field[1]?>"></td></tr>
<?php
}
?>
</table>
<?php
$editnum=$j;
}
}
?>
</td>
</tr>
<tr>
<td height="25">扩展数量: <input name="mveditnum_yspic" type="hidden" id="mveditnum_yspic" value="<?=$editnum?>">
<input name="mvnum_yspic" type="hidden" id="mvnum_yspic" value="2">
<input name="mvmust_yspic" type="hidden" id="mvmust_yspic" value="1">
<input name="mvaddnum_yspic" type="text" id="mvaddnum_yspic" value="1" size="6"> <input type="button" name="Submit5" value="输出" onclick="javascript:domvadd_yspic();"></td>
</tr>
<tr>
<td id="mvadd_yspic"></td>
</tr>
</table>
然后步骤你应该清楚了:请看图片:
如果点击图片出现这样的情况:
不要急,这说明你是帝国cms7.2,请到这个地方完成以下步骤就可以了:
require('../class/connect.php'); //引入数据库配置文件和公共函数文件
require('../class/db_sql.php'); //引入数据库操作文件
$link=db_connect(); //连接MYSQL
$empire=new mysqlquery(); //声明数据库操作类
$editor=1; //声明目录层次
$id = intval($_GET['id']); //获取请求的页数
$catid = intval($_GET['catid']); //获取请求的页数
$start = $page*6;
$sql=$empire->query("SELECT a.title,a.newstime,a.yspic,b.morepic FROM {$dbtbpre}ecms_photo a,{$dbtbpre}ecms_photo_data_1 b WHERE a.id=b.id AND a.id='$id' ");
while($r=$empire->fetch($sql)){
$pic=$r[titlepic]?$r[titlepic]:'/e/data/images/notimg.gif';
if($r[morepic]==''){
return '0';
}else{
str_replace("\r\n","\n",$r['morepic']);
$arr1 = explode("\n",$r['morepic']);
$arr3=array();
$arr4=array();
$arr5=array();
foreach($arr1 as $k1=>$val1){
$arr2=explode("::::::",$val1);
$arr3[]=$arr2[0];
$arr4[]=$arr2[1];
$arr5[]=$arr2[2];
}
}
if($r[yspic]==''){
return '0';
}else{
$arr = explode("||||||",$r['yspic']);
$arr6=array();
$arr7=array();
foreach($arr as $k2=>$val2){
$arr8=explode("::::::",$val2);
$arr6[]=$arr8[0];
$arr7[]=$arr8[1];
}
}
$sayList[] = array('title'=>$r['title'], 'pics'=>$arr3, 'bpic'=>$arr4, 'picname'=>$arr5, 'yspic'=>$arr6,'yspicname'=>$arr7);
}