duanhuau567787 2015-12-05 11:10
浏览 47
已采纳

获取php变量中的输入标记值,无需表单操作

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. Now i am trying to access id's when i click on any of the hover list. 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
    }
    ?>

  • 写回答

2条回答 默认 最新

  • doulang2311 2015-12-05 11:18
    关注

    Don't use input field for that if you want on click then add argument in link like

    <li>  <a href="<?php echo "index.php?page=".$row1['s_cat_name']."&s_cat_id=".$row1['s_cat_id']; ?>"></a></li>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr