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

📄 adm_sort.php

📁 这个版本只是修正了一些BUG
💻 PHP
字号:
<?php
/***********************************************
	adm_sort.php

	Version  : 1.2
	Author   : Tracemouse (tracemouse@msn.com)
	Copyright: http://www.vitci.com
	Writed   : 2003/10/20
	Modified : 2004/04/02
************************************************/
require "./common.php";
$file_name='./adm_sort.php';

if ((!$listsubmit)&&(!$editsubmit)&&(!$adgroupsbm)&&(!$adsortsbm)&&(!$adsubsbm))             //未发送表单
{
	if ($action == 'chg')         //修改页面
	{
		$query = $db->query("select * from $table_sorts where sortid=$sortid");
 		if($dbq_rec = $db->fetch_array($query))
    		{
    			$sortname = $dbq_rec['sortname'];
    			$supsortid = $dbq_rec['supsortid'];
    			$remarks = $dbq_rec['remarks'];
    			$sortid=$dbq_rec['sortid'];
    			$class=$dbq_rec['class'];
//    			$displayorder=$dbq_rec['displayorder'];
 		}
 		if($class=="sort")
 		{
 			$condition="where class='group' order by sortid";
 		}
 		elseif($class=="sub")
 		{
 			$condition="where class='sort' order by sortid";
 		}
 		$query = $db->query("select sortid,sortname from $table_sorts $condition");
	        $supselect="";
 		while($dbq_rec = $db->fetch_array($query))
    		{
   			$isselected = ($dbq_rec['sortid'] == $supsortid)?"selected":"";
   			$supselect .="<option $isselected value='$dbq_rec[sortid]'>$dbq_rec[sortname]</option>";
 		}
 		$display = 'edit';
	}
    	elseif ($action == 'del')              //删除记录
	{
   		$query=$db->query("select count(*) from $table_sorts where supsortid = $sortid");
    		$sortnum = $db->result($query,0);
    		$query=$db->query("select count(*) from $table_products where sortid = $sortid");
    		$productnum = $db->result($query,0);
		if (($sortnum == 0) && ($productnum == 0))
    		{
           		 $sqlstr="delete from $table_sorts where sortid = $sortid";
            		if($query=$db->query($sqlstr))
        			gotourl($language['delsuccess'],$file_name);
            		else
                		gotourl($language['db_err'].":<br>".$sqlstr);
    		}
    		else
    		{
    			gotourl($language['alt_sort_notnull']);
    		}
	}
	else                                //列表页面
	{
		$sortlist = array();
       		$query = $db->query("select * from $table_sorts where class='group' order by displayorder");
       	 	while($dbq_rec = $db->fetch_array($query))
    		{
            		$sortid=$dbq_rec['sortid'];
            		$displayorder=$dbq_rec['displayorder'];
            		$sortlist[] = $dbq_rec;
            		$query1 = $db->query("SELECT * FROM $table_sorts WHERE supsortid = $sortid order by displayorder");
   			while($dbq_rec1 = $db->fetch_array($query1))
   			{
                		$sortid=$dbq_rec1['sortid'];
                		$queryn=$db->query("SELECT COUNT(*) FROM $table_products WHERE sortid=$sortid");
                		$dbq_rec1['productnum']=$db->result($queryn,0);
                		$sortlist[]=$dbq_rec1;
    				$query2 = $db->query("SELECT * FROM $table_sorts WHERE supsortid = $sortid order by displayorder");
    				while($dbq_rec2 = $db->fetch_array($query2))
    				{
					$sortid=$dbq_rec2['sortid'];
                    			$queryn=$db->query("SELECT COUNT(*) FROM $table_products WHERE sortid=$sortid");
                    			$dbq_rec2['productnum']=$db->result($queryn,0);
                    			$sortlist[]=$dbq_rec2;
    				}
  			}
        	}
        	unset($dbq_rec);unset($dbq_rec1);unset($dbq_rec2);unset($query1);unset($query2);unset($queryn);
 		$query=$db->query("select * from $table_sorts where class='group' order by sortid");
 		$groupselect="";
 		while($dbq_rec=$db->fetch_array($query))
 		{
 			$groupselect.="<option value=$dbq_rec[sortid]>$dbq_rec[sortname]</option>";
 		}
 		$query=$db->query("select * from $table_sorts where class='sort' order by sortid");
 		$sortselect="";
 		while($dbq_rec=$db->fetch_array($query))
 		{
 			$sortselect.="<option value=$dbq_rec[sortid]>$dbq_rec[sortname]</option>";
 		}
 		$display = 'list';
	}
}
elseif($listsubmit)
{
	 $query=@$db->query("select * from $table_sorts where class='group' order by sortid",1);
	 while($dbq_rec=$db->fetch_array($query))
	 {
	 	$sortid=$dbq_rec[sortid];
	 	$sqlstr="update $table_sorts set sortname='$upd_sortname[$sortid]',displayorder='$upd_displayorder[$sortid]' where sortid=$sortid";
		@$db->query($sqlstr,1);	
	 }
	 $query=@$db->query("select * from $table_sorts where class='sort' order by sortid",1);
	 while($dbq_rec=$db->fetch_array($query))
	 {
	 	$sortid=$dbq_rec[sortid];
	 	$sqlstr="update $table_sorts set displayorder='$upd_displayorder[$sortid]' where sortid=$sortid";
		@$db->query($sqlstr,1);	
	 }	 
	 gotourl($language['editsuccess'],$file_name);
}
elseif($adgroupsbm)
{
	$sqlstr = "insert into $table_sorts(sortname,supsortid,remarks,class) ".
        		"values('$sortname',0,'$remarks','group')";
        if($query = @$db->query($sqlstr,1))
  		gotourl($language['editsuccess'],$file_name);
        else
           	gotourl($language['db_err'].":<br>".$sqlstr);  	
}
elseif($adsortsbm)
{
	if($supsortid == 0)  gotourl($language['sort_err_nogroup']);
	$sqlstr = "insert into $table_sorts(sortname,supsortid,remarks,class) ".
        		"values('$sortname',$supsortid,'$remarks','sort')";
        if($query = @$db->query($sqlstr,1))
  		gotourl($language['editsuccess'],$file_name);
        else
           	gotourl($language['db_err'].":<br>".$sqlstr);  	
}
elseif($adsubsbm)
{
	if($supsortid == 0)  gotourl($language['sort_err_nosort']);
	$sqlstr = "insert into $table_sorts(sortname,supsortid,remarks,class) ".
        		"values('$sortname',$supsortid,'$remarks','sub')";
        if($query = @$db->query($sqlstr,1))
  		gotourl($language['editsuccess'],$file_name);
        else
           	gotourl($language['db_err'].":<br>".$sqlstr);  	
}
elseif ($editsubmit)    
{
        $sqlstr = "update $table_sorts set sortname='$sortname',".
        		"supsortid=$supsortid,remarks='$remarks' where sortid = $sortid";
        if($query = @$db->query($sqlstr,1))
  			gotourl($language['editsuccess'],$file_name);
        else
           		gotourl($language['db_err'].":<br>".$sqlstr);
}

include template('sort');
?>

⌨️ 快捷键说明

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