[英]get input tag value in php variable without form action
I have a navigation which is dynamically set through database. 我有一个通过数据库动态设置的导航。 I have a category and subcategory table. 我有一个类别和子类别表。 I have arranged my navigation bar with category table and using its foreign key when i hover over category it shows it's subcategories.It is working correctly! 当我将鼠标悬停在类别上时,它已经显示了它的子类别。 I have given a input value with both category and subcategory which is hidden and it consist of cat_id
and s_cat_id
.Both are primary keys of category table and subcategory table. 我给了一个包含类别和子类别的输入值,该输入值是隐藏的,它由cat_id
和s_cat_id
组成。 s_cat_id
都是类别表和子类别表的主键。 Now i am trying to access id's when i click on any of the hover list. 现在,当我单击任何悬停列表时,我都尝试访问ID。 I am stuck here. 我被困在这里。 Any suggestions will be highly appreciated! 任何建议将不胜感激!
Code 码
<ul id="nav">
<?php
$res=mysqli_query($con,"SELECT * FROM category");
while($row=mysqli_fetch_array($res))
{
?>
<li>
<li> <a href="<?php echo "index.php?page=".$row1['s_cat_name']."&s_cat_id=".$row1['s_cat_id']; ?>"><?php echo $row1['s_cat_name'];?></a></li>
<ul>
<?php
$result=mysqli_query($con,"SELECT * FROM subcategory WHERE cat_id=".$row['cat_id']);
while($row1=mysqli_fetch_array($result))
{
?>
<li> <a href="<?php echo "index.php?mode=2&page=".$row1['s_cat_name']; ?>"><?php echo $row1['s_cat_name'] ?><input type="" name="s_cat_id" value="<?php echo $row1['s_cat_id'] ?>"></a></li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
如果要单击,请不要在该字段中使用输入,然后在链接之类的位置添加参数
<li> <a href="<?php echo "index.php?page=".$row1['s_cat_name']."&s_cat_id=".$row1['s_cat_id']; ?>"></a></li>
You have different errors int he part were you tried: 您尝试了部分操作时遇到了其他错误:
<?php
$page= $_GET['page'];
//This is what i have tried
$catid=$_POST['cat_id'];
echo $catid;
$scatid=$_POST['s_cat_id'];
echo $scatid;
?>
Try to change all the POST
to GET
尝试将所有POST
更改为GET
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.