pdo中的html按钮

ac1kyiln  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(302)

我试着用pdo在mysql中做一个select,并用返回的数据做一个列表,但是我需要在每个“div”中放一个按钮,为了改变表,我试着放一个 if(isset($_POST[''])) ,但忘了它没有工作,我没有任何其他方法来做这件事。

$stmt = $PDO -> prepare("SELECT idP, a, b, c, d, e FROM tblP inner join tblC WHERE idPP = ? and aP = 0 and fP = 0 and idCP = idC");
    $stmt -> bindParam(1, $_SESSION["idP"]);
    $stmt -> execute();

    $query = $stmt -> fetchAll(PDO::FETCH_BOTH);

    $result = count($query);

    $query = array_chunk($query, $result);

    for ($i = 0; $i < $result; $i++){

        $idP = $query[0][$i][0];

        $dP = $query[0][$i][1];

        $lP = $query[0][$i][2];

        $nC = $query[0][$i][3]." ".$query[0][$i][4];

        $cC = $query[0][$i][5];

        echo '<div class="p2345">
             <h3>P ID:</h3><br><a>'.$idP.'</a> 
             <br><br> 
             <h3>Description of P:</h3><br>'. $dP.' 
             <br><br> <a href="'.$lP.'">Link of Archive</a> 
             <br><br> 
             <h3>N of the Cliente:</h3><br><a>'. $nC.' 
             <br><br> 
             <h3>C of the Cliente</h3><br><a>'. $cC.' 
             <br><br> 
             <input type="submit" name="btnC" value="Accept P">
             <input type="submit" name="btnR" value="Refuse P">  
             </div> 
             <br>'; 

        echo "--------------------------------------------";
    }
oyjwcjzk

oyjwcjzk1#

那是因为没有任何东西在发送邮件。要么使用ajax(javascript),要么在按钮周围放一个。。。表单发送post或get,而不是按钮。

echo '<div class="p2345">
         <h3>P ID:</h3><br><a>'.$idP.'</a> 
         <br><br> 
         <h3>Description of P:</h3><br>'. $dP.' 
         <br><br> <a href="'.$lP.'">Link of Archive</a> 
         <br><br> 
         <h3>N of the Cliente:</h3><br><a>'. $nC.' 
         <br><br> 
         <h3>C of the Cliente</h3><br><a>'. $cC.' 
         <br><br>
         <form method="post" action=""> 
           <input type="submit" name="btnC" value="Accept P">
           <input type="submit" name="btnR" value="Refuse P">   
         </form>
         </div> 
         <br>';

至于抓住它,把它放在你的剧本上面;

if(isset($_POST['btnC'] || isset($_POST['btnR'])){
 //do stuff here
}

相关问题