首页 > 解决方案 > html中的按钮单击和php没有响应

问题描述

这是按钮<button type='submit' name="myBtn" id="myBtn" class="btn btn-primary ml-5">Match</button>

这是PHP中应该触发的部分

<?php
    if(isset($_POST['myBtn']))
    {
        echo "in";
        $q=mysqli_query($con,"SELECT id FROM members1 WHERE name='$username'");
        $conv=$q->fetch_assoc();
        $id=(int)$conv['id'];
        $res=mysqli_query($con,"SELECT * FROM interests WHERE perId='$id'");
        $row=mysqli_num_rows($res);
        $c=0;
        foreach ($_GET['interests'] as $selectedOption)
            $c=$c+1;
        $result=($c/$row)*100;
        echo $result;
    }
?>

另外,如果有人能告诉我如何将我在 $q 中收到的 id 转换为整数,我将不胜感激。我不认为我所做的是正确的。

初学者在这里,提前谢谢。

标签: phphtml

解决方案


推荐阅读