⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modify_pro.php

📁 中观在线zol的后台管理代码
💻 PHP
字号:
<?php 
require_once("../../config.inc.php");
$area_id = (int)$_GET['area_id'];
$manu_id = (int)$_GET['manuid'];

if( $_POST['pro_name'] ){
$pro_name = $_POST['pro_name'];
//and level>10表示没有停产
$sql = "select z_productid,z_name,z_sid from z_product_tmp where  z_name like '%{$pro_name}%' and z_inarea=0 order by z_id  ";
$product_arr = $DB_Read->get_results($sql,'O');


}

//删除关联
if( $_POST['ACT']=="delete" ){

	$use_for_delete = $_POST['del_arr'];
	if( $use_for_delete ){
		foreach ($use_for_delete as $item ){
			$sql = "delete from z_area_products where z_productid={$item}";
			$DB_Write->query($sql);
			$sql = "update z_product_tmp set z_inarea=0 where z_productid={$item}";
			$DB_Write->query($sql);
		}
	}
}
//去已关联的产品
//foreach ( $relation as $item ){
//	if( $item->z_productid )
//}
//print_r($relation);
if( $_POST['ACT']=="select" ){
	$use_for_select = $_POST['pro_arr'];
	//取最大排序值
	$sql = "select z_sort from z_area_products  where z_areaid={$area_id} order by z_sort desc limit 1";
	$max_sort = $DB_Read->get_var($sql);
	$max_sort = $max_sort?$max_sort:0; 
	
	if( is_array($use_for_select) ){
		foreach ( $use_for_select as $item ){
			$sql = "insert into z_area_products(z_areaid,z_productid,z_sort) values ({$area_id},{$item},".($max_sort+1).")";
			$DB_Write->query($sql);
			$sql = "update z_product_tmp set z_inarea=1 where z_productid={$item}";
			$DB_Write->query($sql);
			$max_sort ++;
		}
	}
	
//	print($use_for_select);
}

//现有已关联产品
$sql = "select z_productid from z_area_products where z_areaid={$area_id} ";
$now_have = $DB_Read->get_results($sql,"O");
//查询区名
$sql = "select z_name from z_area where z_id={$area_id}";
$area_name = $DB_Read->get_var($sql);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="author" content="shenjianhong" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>关联产品</title>
<link href="../include/css/area.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="td_bd1 f18"><?php echo $area_name;?>  设置</td>
  </tr>
    <form id="sel_pro" name="sel_pro" method="post" action="">
  <tr>
    <td align="left"><table width="90%" border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
      <tr>
        <td bgcolor="#FFFFFF" ><input type="hidden" name="ACT" id="" value="delete"/></td>
        <td bgcolor="#FFFFFF"></td>
      </tr>
      
     <?php

     if( is_array($now_have) ){ 
     $i=0;
     foreach ( $now_have as $item ){	
     	$sql = "select z_name from z_product_tmp where z_productid={$item->z_productid} ";
     	$pro_name = $DB_Read->get_var($sql);
   		if( $i%2==0 ){echo "<tr>";}
		echo ' <td algin="left"><input name="del_arr[]" type="checkbox" value="'.$item->z_productid.'"/>';
        echo $pro_name.'</td>';
   		if( $i%2==1 ){echo "</tr>";}
     	$i++;
     } 
     }
     ?> 


    </table>
    <br /></td>
  </tr>
  <tr>
    <td align="center"><div align="left"></div></td>
  </tr>
  <tr>
    <td align="center"><div align="left">
      <input type="submit" name="delSubmit" value="删除关联" />
    </div></td>
  </tr>
  </form>
  <tr>
    <td align="center">&nbsp;</td>
  </tr>
  <tr></tr>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="90%" border="0" align="left" cellpadding="0" cellspacing="5">
      <tr>
        <td width="50">产品:</td>
        <form id="form1" name="form1" method="post" action="">
        <td><input name="pro_name" type="text" style="border:1px solid #666;font:14px/16px simsun;padding:2px" />
          &nbsp;
          <input type="submit" name="Submit3" value="搜索" /></td>
         </form>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td class="lv12 f12">此处调取的是没有关联大区的其它产品,按产品录入时间倒序</td>
      </tr>
    </table>      </td>
  </tr>
  <form id="sel_pro" name="sel_pro" method="post" action="">
  <tr>
    <td><table width="90%" border="0" align="left" cellpadding="0" cellspacing="0">
        
      <tr>
        <td>&nbsp;<input type="hidden" name="ACT" id="" value="select"/></td>
        <td>&nbsp;</td>
      </tr>
     <?php
     if( is_array($product_arr) ){ 

     $i=0;
     foreach ( $product_arr as $item ){
     	
   		if( $i%2==0 ){echo "<tr>";}
		echo ' <td><input name="pro_arr[]" type="checkbox" value="'.$item->z_productid.'"/>';
        echo $item->z_name.'</td>';
   		if( $i%2==1 ){echo "</tr>";}
     	$i++;
     } 
     }
     ?> 

    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td> <?php  if( is_array($product_arr) ){ ?><input type="submit" name="Submit22" value="确定" /><?php }?></td>
  </tr>
</form>
</table>
<p align="center">&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -