产品页面的三级分类 添加到产品表里面的时候怎么取值呢?
因为有时候我可能只在一级类里面添加图片,也可能在二级类里面添加图片,也可能在三级类里面添加图片那么我如何取值呢?用判断吗?<scriptlanguage="JavaScr...
因为有时候我可能只在一级类里面添加图片,也可能在二级类里面添加图片,也可能在三级类里面添加图片 那么我如何取值呢?用判断吗?
<script language="JavaScript">
<!--
var subcat = new Array();
<?php
$i=0;
$sql="select * from dj_jiayao_type where flid=2";
$query=mysql_query($sql,$link);
while($arr=mysql_fetch_array($query))
{
echo "subcat[".$i++."] = new Array('".$arr["tid"]."','".$arr["type"]."','".$arr["id"]."');\n";
}
?>
var subcat2 = new Array();
<?php
$i=0;
$sql="select * from dj_jiayao_type where flid=3";
$query=mysql_query($sql,$link);
while($arr=mysql_fetch_array($query))
{
echo "subcat2[".$i++."] = new Array('".$arr["tid"]."','".$arr["type"]."','".$arr["id"]."');\n";
}
?>
function changeselect1(locationid)
{
document.myform.s2.length = 0;
document.myform.s2.options[0] = new Option('==请选择==','');
for (i=0; i<subcat.length; i++)
{
if (subcat[i][0] == locationid)
{document.myform.s2.options[document.myform.s2.length] = new Option(subcat[i][1], subcat[i][2]);}
}
}
function changeselect2(locationid)
{
document.myform.s3.length = 0;
document.myform.s3.options[0] = new Option('==请选择==','');
for (i=0; i<subcat2.length; i++)
{
if (subcat2[i][0] == locationid)
{document.myform.s3.options[document.myform.s3.length] = new Option(subcat2[i][1], subcat2[i][2]);}
}
}
//-->
</script>
<select name="s1" onChange="changeselect1(this.value)">
<option>==请选择==</option>
<?php
$sql="select * from dj_jiayao_type where flid=1";
$query=mysql_query($sql,$link);
while($arr=mysql_fetch_array($query))
{
echo "<option value=".$arr["id"].">".$arr["type"]."</option>\n";
}
?>
</select>
<select name="s2" onChange="changeselect2(this.value)">
<option>==请选择==</option>
</select>
<select name="s3" onChange="changeselect3(this.value)">
<option>==请选择==</option>
</select>
这个是添加页
$title = $_POST["title"];
$content = $_POST["content1"];
$s1 = $_POST["s1"];
$s2 = $_POST["s2"];
$s3 = $_POST["s3"];
if($s3<>""){
$tid = $s3;
}
elseif($s2<>"" || $s3=="")
{$tid=$s2;}
elseif($s2==""){
$tid = $s1;
}
echo $tid;
$adddate = gmdate("Y-m-d H:i:s",time()+8*3600); //echo $addtime = date('Y-m-d H:i:s');
if (mysql_query("insert into dj_jiayao(title,pic,content,tid,time,tj)values('$title','$pic','$content','$tid','$adddate',1)"))
{
echo "insert into dj_jiayao(title,pic,content,tid,time,tj)values('$title','$pic','$content','$tid','$adddate',1)";
echo "<script>alert('˼Ϣӳɹ!');location.href='admin_jiayao.php';</script>";
}
else{
echo "<script>alert('ʧ!');history.go(-1)</script>";
}
?>
不知道思路对了没 请指点 展开
<script language="JavaScript">
<!--
var subcat = new Array();
<?php
$i=0;
$sql="select * from dj_jiayao_type where flid=2";
$query=mysql_query($sql,$link);
while($arr=mysql_fetch_array($query))
{
echo "subcat[".$i++."] = new Array('".$arr["tid"]."','".$arr["type"]."','".$arr["id"]."');\n";
}
?>
var subcat2 = new Array();
<?php
$i=0;
$sql="select * from dj_jiayao_type where flid=3";
$query=mysql_query($sql,$link);
while($arr=mysql_fetch_array($query))
{
echo "subcat2[".$i++."] = new Array('".$arr["tid"]."','".$arr["type"]."','".$arr["id"]."');\n";
}
?>
function changeselect1(locationid)
{
document.myform.s2.length = 0;
document.myform.s2.options[0] = new Option('==请选择==','');
for (i=0; i<subcat.length; i++)
{
if (subcat[i][0] == locationid)
{document.myform.s2.options[document.myform.s2.length] = new Option(subcat[i][1], subcat[i][2]);}
}
}
function changeselect2(locationid)
{
document.myform.s3.length = 0;
document.myform.s3.options[0] = new Option('==请选择==','');
for (i=0; i<subcat2.length; i++)
{
if (subcat2[i][0] == locationid)
{document.myform.s3.options[document.myform.s3.length] = new Option(subcat2[i][1], subcat2[i][2]);}
}
}
//-->
</script>
<select name="s1" onChange="changeselect1(this.value)">
<option>==请选择==</option>
<?php
$sql="select * from dj_jiayao_type where flid=1";
$query=mysql_query($sql,$link);
while($arr=mysql_fetch_array($query))
{
echo "<option value=".$arr["id"].">".$arr["type"]."</option>\n";
}
?>
</select>
<select name="s2" onChange="changeselect2(this.value)">
<option>==请选择==</option>
</select>
<select name="s3" onChange="changeselect3(this.value)">
<option>==请选择==</option>
</select>
这个是添加页
$title = $_POST["title"];
$content = $_POST["content1"];
$s1 = $_POST["s1"];
$s2 = $_POST["s2"];
$s3 = $_POST["s3"];
if($s3<>""){
$tid = $s3;
}
elseif($s2<>"" || $s3=="")
{$tid=$s2;}
elseif($s2==""){
$tid = $s1;
}
echo $tid;
$adddate = gmdate("Y-m-d H:i:s",time()+8*3600); //echo $addtime = date('Y-m-d H:i:s');
if (mysql_query("insert into dj_jiayao(title,pic,content,tid,time,tj)values('$title','$pic','$content','$tid','$adddate',1)"))
{
echo "insert into dj_jiayao(title,pic,content,tid,time,tj)values('$title','$pic','$content','$tid','$adddate',1)";
echo "<script>alert('˼Ϣӳɹ!');location.href='admin_jiayao.php';</script>";
}
else{
echo "<script>alert('ʧ!');history.go(-1)</script>";
}
?>
不知道思路对了没 请指点 展开
1个回答
云创
2023-07-25 广告
2023-07-25 广告
代码静态分析服务可以帮助开发人员在代码编写过程中发现问题和错误,提高代码质量和安全性。以下是在某些方面可能会提供折扣的例子:1. 高频使用的服务:如果一个组织或个人频繁使用代码静态分析服务,那么他们可能会获得与使用频率相关的折扣。例如,每次...
点击进入详情页
本回答由云创提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询