此为后台管理界面:
<?
$con = mysql_connect("localhost","","");
mysql_select_db("xinwen", $con);//test改为你的库名
$k = ($_GET[k]) ? $_GET[k] : 1;
$dir = array(1=>"添加类别","添加品牌","添加耗材","耗材列表");
$title = "耗材管理";
$rs = mysql_query("select * from first order by id");
$karr = array();
echo"<script LANGUAGE='JavaScript'>
karr = [";
while($row = @mysql_fetch_row($rs)){
if(!$initkey) $initkey = $row[0];
$key = $row[0];
$karr[$key] = $row[1];
echo"'$row[1]',";
}
$kn = count($karr);
echo"''] /r/n kn=$kn /r/n ";
$selk = ($_POST[selk]) ? $_POST[selk] : $_POST[selg];
$selk = $selk ? $selk : $initkey;
if($_GET["edid"]&&!$_POST["nosub"]){
$rs1 = mysql_query("select * from products where id='$_GET[edid]'");
$row1 = @mysql_fetch_array($rs1);
$selk =$row1[groupid];
}
$rs = mysql_query("select id,name from second where groupid = '$selk' order by id");
$barr = array();
echo"barr = [";
while($row = @mysql_fetch_row($rs)){
$key = $row[0];
$barr[$key] = $row[1];
echo"'$row[1]',";
}
$bn = count($barr);
echo"''] /r/n bn=$bn /r/n </script>/r/n";
if($_POST["kname"]){
mysql_query("insert into first set name='$_POST[kname]'");
echo"<script LANGUAGE='JavaScript'>alert('新增类别已保存');location=location</script>"; return;
}
if($_POST["bname"]&&!$_POST["nosub"]){
mysql_query("insert into second set groupid='$_POST[selk]',name='$_POST[bname]'");
echo"<script LANGUAGE='JavaScript'>alert('新增品牌已保存');location=location</script>"; return;
}
if($_POST["nosub"]){
echo"<script LANGUAGE='JavaScript'>
function init(){
document.form1.selk.value='$_POST[selk]'/r/n";
if($_POST["nosub"]==2) echo"document.form1.selb.value='$_POST[selb]'/r/n";
echo"}
</script>/r/n";
$onload = "οnlοad='init()'";
}else if($_GET["edid"]){
echo"<script LANGUAGE='JavaScript'>
function init(){
obj=document.form1
obj.selk.value='$row1[groupid]'
for(i=0;i<obj.selb.options.length;i++){
if(obj.selb.options[i].innerText=='$row1[pinpai]'){
obj.selb.selectedIndex=i ; break;
}