更新时间:2023-02-01 10:53:36
最后只是要弄清楚我自己,但感谢那些谁试图帮助。
Finally just had to figure it out on my own, but thanks for those who tried to help.
我将公布我的类/分类/类型/类型的层叠表我的中间表。首先做一个函数,如下面的:
I will post my middle table from my Class/Category/Style/Type cascading tables. First make a function such as the below:
<?php //Category Selection
function Category_Selection($link) {
global $connection;
$options="";
if(isset($_GET["class_id"])) {
$query="SELECT categories.category_id, categories.Category_Name ";
$query.="FROM categories ";
$query.="ORDER BY categories.Category_Name ASC";
$result=mysql_query($query, $connection);
$class_id=$_GET['class_id'];
if(!$result){
die("Database query failed: " . mysql_error());
}
while ($row=mysql_fetch_array($result)) {
$name=$row["Category_Name"];
$id=$row["category_id"];
$link2=$link."&category_id={$id}";
$options.="<OPTION VALUE=\"$link2\" ";
if(isset($_GET["category_id"])) {
$category_id = $_GET['category_id'];
if($id==$category_id) {
$options.=" selected=\"selected\" ";
}
}
$options.=" >".$name.'</OPTION>';
}
} else {
$options.="<OPTION selected=\"selected\" VALUE=0>First Select Class</OPTION>";
}
return($options);
}
?>
然后把你的主页:
Then place on your main page:
<?php session_start() ?>
//Category
if(isset($_GET['category_id'])) {
$category_id=$_GET['category_id'];
setcookie('category_id',$category_id);
$link.="&category_id={$category_id}";
}elseif(isset($_COOKIE['category_id'])) {
$_GET['category_id']=$_COOKIE['category_id'];
$category_id=$_COOKIE['category_id'];
$link.="&category_id={$category_id}";
}
现在让你选择下拉:
<?php //Category Selection
$options=Category_Selection($link);
?>
<center>
<SELECT NAME="category_id" ONCHANGE="location = this.options[this.selectedIndex].value;">
<OPTION VALUE=0></OPTION>
<?php echo $options ?>
</SELECT>
</center>
重复上述每个要求的下拉
Repeat above for each required drop-down.
祝你好运......,当然使用的mysqli来保护你的网站,而不是上面显示的MYSQL ......
Good luck...and, of course use MYSQLi to protect your site rather than the MYSQL shown above...