PDO update table using array

后端 未结 2 1757
北海茫月
北海茫月 2021-01-26 17:53

I\'m learning and new in PDO. The usage of array in PDO causes difficulty for me. I\'m developing simple web application using PDO syntax. Everything is going on smoothly, but I

2条回答
  •  不知归路
    2021-01-26 18:16

    Use for loop for this operation as there are no associative arrays involved

    if(isset($_POST['submit'])){
    
    $name = array();// initialize it first for a good coding standard
    $roll = array();// initialize it first for a good coding standard
    $name = $_POST['name'];
    $roll = $_POST['roll'];
    
    for($i=0;$iprepare($sql);
        $query->bindparam(':roll', $name[$i]);
        $query->bindparam(':name', $roll[$i]);
        $query->execute();
    }
    }
    

提交回复
热议问题