模板啦-优秀的帝国cms网站模板资源分享学习平台!

如何在数据表中增加多个图片字段morepic

来源:模版啦原创作者:二师兄 发布时间:2019-05-16 12:10:32

新建一个字段值:mobanpic
替换:输入表单替换html代码值: 这里的演示字段是mobanpic,其他请自行替换:

<script>
function domobanpicadd()
{var i;
var str="";
var oldi=0;
var j=0;
oldi=parseInt(document.add.mobanpicnum.value);
for(i=1;i<=document.add.downmobanpicnum.value;i++)
{
j=i+oldi;
str=str+"<tr><td width=7%><div align=center>"+j+"</div></td><td width=33%><div align=center><input name=msmallmobanpic[] type=text size=28 id=msmallmobanpic"+j+" ondblclick=SpOpenChFile(1,'msmallmobanpic"+j+"')><br><input type=file name=msmallmobanpfile[] size=15></div></td><td width=30%><div align=center><input name=mbigmobanpic[] type=text size=28 id=mbigmobanpic"+j+" ondblclick=SpOpenChFile(1,'mbigmobanpic"+j+"')><br><input type=file name=mbigmobanpfile[] size=15></div></td><td width=30%><div align=center><input name=mmobanpicname[] type=text></div></td></tr>";
}
document.getElementById("addmobanpicdown").innerHTML="<table width='100%' border=0 cellspacing=1 cellpadding=3>"+str+"</table>";
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25">
      图片地址前缀:
      <input name="mmobanpicurl_qz" type="text" id="mmobanpicurl_qz">&nbsp;&nbsp;
        <input type="checkbox" name="msavemobanpic" value="1">远程保存&nbsp;<input type="checkbox" name="mcreatesmobanpic" value="1" onclick="if(this.checked){setmcreatesmobanpic.style.display='';}else{setmcreatesmobanpic.style.display='none';}">生成缩图
        <span id="setmcreatesmobanpic" style="display:none">:<input type=text name="mcreatesmobanpicwidth" size=4 value="<?=$public_r[spicwidth]?>">*<input type=text name="mcreatespicheight" size=4 value="<?=$public_r[spicheight]?>">(宽*高)</span>
<?php
if(TranmoreIsOpen())
{
?>
<input type="button" name="Submit" value="多选上传" onclick="window.open('ecmseditor/tranmore/tranmore.php?type=1&classid=<?=$classid?>&filepass=<?=$filepass?>&infoid=<?=$id?>&modtype=0&sinfo=1&ecmsdo=ecmstmmobanpic&tranfrom=2<?=$ecms_hashur['ehref']?>&oldmobanpicnum='+document.add.mobanpicnum.value,'ecmstmpage','width=700,height=550,scrollbars=yes');">
<?php
}
?>
</td>
  </tr>
  <tr>
    <td><table width="100%" border=0 align=center cellpadding=3 cellspacing=1>
  <tr bgcolor="#DBEAF5">
    <td width="7%"><div align=center>编号</div></td>
    <td width="33%"><div align=center>缩图 <font color="#666666">(双击选择)</font></div></td>
    <td width="30%"><div align=center>大图 <font color="#666666">(双击选择)</font></div></td>
    <td width="30%"><div align=center>图片说明</div></td>
  </tr>
</table></td>
  </tr>
  <tr>
    <td id=defmobanpicid>
    <?php
    if($ecmsfirstpost==1)
    {
      ?>
      <table width='100%' border=0 align=center cellpadding=3 cellspacing=1>
      <?php
      $mobanpicnum=3;
      for($mppathi=1;$mppathi<=$mobanpicnum;$mppathi++)
      {
      ?>
      <tr>
           <td width='7%'><div align=center><?=$mppathi?></div></td>
           <td width='33%'><div align=center>
           <input name=msmallmobanpic[] type=text id='msmallmobanpic<?=$mppathi?>' size=28 ondblclick="SpOpenChFile(1,'msmallmobanpic<?=$mppathi?>');">
           <br><input type=file name=msmallmobanpfile[] size=15>
           </div></td>
           <td width='30%'><div align=center>
           <input name=mbigmobanpic[] type=text id='mbigmobanpic<?=$mppathi?>' size=28 ondblclick="SpOpenChFile(1,'mbigmobanpic<?=$mppathi?>');">
           <br><input type=file name=mbigmobanpfile[] size=15>
           </div></td>
           <td width='30%'><div align=center>
           <input name=mmobanpicname[] type=text id='mmobanpicname<?=$mppathi?>'>
           </div></td>
      </tr>
      <?php
      }
      ?>
      </table>
      <?php
    }
    else
    {
      $mobanpicpath="";
      $mobanpicnum=0;
      if($r[mobanpic])
          {
               $r[mobanpic]=stripSlashes($r[mobanpic]);
               //地址
               $j=0;
               $pd_record=explode("\r\n",$r[mobanpic]);
               for($i=0;$i<count($pd_record);$i++)
               {
                 $j=$i+1;
                     $pd_field=explode("::::::",$pd_record[$i]);
                 $mobanpicpath.="<tr>
    <td width='7%'><div align=center>".$j."</div></td>
    <td width='33%'><div align=center>
        <input name=msmallmobanpic[] type=text value='".$pd_field[0]."' size=28 id=msmallmobanpic".$j." ondblclick=\"SpOpenChFile(1,'msmallmobanpic".$j."');\">
           <br><input type=file name=msmallmobanpfile[] size=15>
      </div></td>
    <td width='30%'><div align=center>
        <input name=mbigmobanpic[] type=text value='".$pd_field[1]."' size=28 id=mbigmobanpic".$j." ondblclick=\"SpOpenChFile(1,'mbigmobanpic".$j."');\">
           <br><input type=file name=mbigmobanpfile[] size=15>
      </div></td>
    <td width='30%'><div align=center>
        <input name=mmobanpicname[] type=text value='".$pd_field[2]."'><input type=hidden name=mmobanpicid[] value=".$j."><input type=checkbox name=mdelmobanpicid[] value=".$j.">删
      </div></td>
  </tr>";
               }
               $mobanpicnum=$j;
               $mobanpicpath="<table width='100%' border=0 cellspacing=1 cellpadding=3>".$mobanpicpath."</table>";
          }
      echo $mobanpicpath;
    }
    ?>
    </td>
  </tr>
  <tr>
    <td height="25">地址扩展数量: <input name="mobanpicnum" type="hidden" id="mobanpicnum" value="<?=$mobanpicnum?>">
      <input name="downmobanpicnum" type="text" value="1" size="6"> <input type="button" name="Submit5" value="输出地址" onclick="javascript:domobanpicadd();"></td>
  </tr>
  <tr>
    <td id=addmobanpicdown></td>
  </tr>
</table> 

替换投稿的html代码也基本一样:如下
 
<script>
function domobanpicadd()
{var i;
var str="";
var oldi=0;
var j=0;
oldi=parseInt(document.add.mobanpicnum.value);
for(i=1;i<=document.add.downmobanpicnum.value;i++)
{
j=i+oldi;
str=str+"<tr><td width=7%><div align=center>"+j+"</div></td><td width=33%><div align=center><input name=msmallmobanpic[] type=text size=28 id=msmallmobanpic"+j+"></div></td><td width=30%><div align=center><input name=mbigmobanpic[] type=text size=28 id=mbigmobanpic"+j+"></div></td><td width=30%><div align=center><input name=mmobanpicname[] type=text></div></td></tr>";
}
document.getElementById("addmobanpicdown").innerHTML="<table width='100%' border=0 cellspacing=1 cellpadding=3>"+str+"</table>";
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25">
      图片地址前缀:
      <input name="mmobanpicurl_qz" type="text" id="mmobanpicurl_qz" size="32">
      &nbsp;</td>
  </tr>
  <tr>
    <td><table width=100% border=0 align=center cellpadding=3 cellspacing=1>
  <tr bgcolor='#DBEAF5'>
    <td width=7%><div align=center>编号</div></td>
    <td width=33%><div align=center>缩图</div></td>
    <td width=30%><div align=center>大图</div></td>
    <td width=30%><div align=center>图片说明</div></td>
  </tr>
</table></td>
  </tr>
  <tr>
    <td id=defmobanpicid>
    <?php
    if($ecmsfirstpost==1)
    {
      ?>
      <table width='100%' border=0 align=center cellpadding=3 cellspacing=1>
      <?php
      $mobanpicnum=3;
      for($mppathi=1;$mppathi<=$mobanpicnum;$mppathi++)
      {
      ?>
      <tr>
           <td width='7%'><div align=center><?=$mppathi?></div></td>
           <td width='33%'><div align=center>
           <input name=msmallmobanpic[] type=text id=msmallmobanpic[] size=28>
           </div></td>
           <td width='30%'><div align=center>
           <input name=mbigmobanpic[] type=text id=mbigmobanpic[] size=28>
           </div></td>
           <td width='30%'><div align=center>
           <input name=mmobanpicname[] type=text id=mmobanpicname[]>
           </div></td>
      </tr>
      <?php
      }
      ?>
      </table>
      <?php
    }
    else
    {
      $mobanpicpath="";
      $mobanpicnum=0;
      if($r[mobanpic])
      {
           $r[mobanpic]=stripSlashes($r[mobanpic]);
           //地址
           $j=0;
           $pd_record=explode("\r\n",$r[mobanpic]);
           for($i=0;$i<count($pd_record);$i++)
           {
                 $j=$i+1;
                 $pd_field=explode("::::::",$pd_record[$i]);
                 $mobanpicpath.="<tr>
      <td width='7%'><div align=center>".$j."</div></td>
    <td width='33%'><div align=center>
        <input name=msmallmobanpic[] type=text value='".$pd_field[0]."' size=28>
      </div></td>
    <td width='30%'><div align=center>
        <input name=mbigmobanpic[] type=text value='".$pd_field[1]."' size=28>
      </div></td>
    <td width='30%'><div align=center>
        <input name=mmobanpicname[] type=text value='".$pd_field[2]."'><input type=hidden name=mmobanpicid[] value=".$j."><input type=checkbox name=mdelmobanpicid[] value=".$j.">删
      </div></td></tr>";
           }
           $mobanpicnum=$j;
           $mobanpicpath="<table width='100%' border=0 cellspacing=1 cellpadding=3>".$mobanpicpath."</table>";
      }
      echo $mobanpicpath;
    }
    ?>
    </td>
  </tr>
  <tr>
    <td height="25">地址扩展数量: <input name="mobanpicnum" type="hidden" id="mobanpicnum" value="<?=$mobanpicnum?>">
      <input name="downmobanpicnum" type="text" value="1" size="6"> <input type="button" name="Submit5" value="输出地址" onclick="javascript:domobanpicadd();"></td>
  </tr>
  <tr>
    <td id=addmobanpicdown></td>
  </tr>
</table>

   

  找到e\class\functions.php 在function ReturnAddF函数中,morepic 流程后插入如下代码   有两个地方需要插入
elseif($f=='mobanpic'){
             $add_temp = [
                 'msmallpic' => $add['msmallmobanpic'],
                 'mbigpic'   => $add['mbigmobanpic'],
                 'mpicname'  => $add['mmobanpicname'],
                 'mdelpicid' => $add['mdelmobanpicid'],
                 'mpicid'    => $add['mmobanpicid'],
                 'mpicurl_qz'=> $add['mmobanpicurl_qz'],
                 'msavepic'  => $add['msavemobanpic'],
                 'mcreatespic'=> $add['mcreatesmobanpic'],
                 'msmallpfile'=> $add['msmallmobanpfile'],
                 'mbigpfile'=> $add['mbigmobanpfile'],
             ];
             //设置_FIELS
             $_FILES['msmallpfile'] = $_FILES['msmallmobanpfile'];
             $_FILES['mbigpfile'] = $_FILES['mbigmobanpfile'];
             $add = array_merge($add,$add_temp);
             $value=ReturnMorepicpath($add['msmallpic'],$add['mbigpic'],$add['mpicname'],$add['mdelpicid'],$add['mpicid'],$add,$add['mpicurl_qz'],1,0,intval($add['fstb']));
         }

本文地址:http://www.muban.la/jc/126.html

本文标题:如何在数据表中增加多个图片字段morepic


联系我们 | 关于我们 | 版权声明 | 帮助中心 | 广告服务 | 网站地图

模板啦专业提供网站模板,网页模板,教程培训,程序插件,网站素材等建站资源。我们致力于打造一个优秀的建站资源共享学习平台!

Copyright @ 2010-2018 模板啦 版权所有 粤ICP备16126808号-1