如何在不复制的情况下使用多个选项列表更新mysql集

时间:2019-06-14 00:37:24

标签: php mysqli

提交此文件时,它会复制前两个sql变量。

elseif (!empty($_POST['kids'])) {

    $kids = $_POST['kids'];

    foreach  ($kids as $c ) {
        $d=date("Y-m-d H:i");
        $kids_string = implode(' ', $_POST['kids']);
        //sql stuff

        $sql = "INSERT INTO kidspu 
                        (parent, childname, timepu) 
                VALUES ('$_SESSION[username]','$kids_string','$d' );";  

        $sql .= "INSERT INTO entered  
                        (parent, childname, timepu, timedo, completed) 
                VALUES ('$_SESSION[username]','$kids_string','$d', '', 'no' );";    

        $sql .= "UPDATE kids SET `pu`='yes' WHERE childname = '". 
                mysqli_real_escape_string($conn , $c)."'";

        if (mysqli_multi_query($conn,$sql)) {
            do {
                // Store first result set
                if ($result=mysqli_store_result($conn)) {
                    // Fetch one and one row
                    while ($row=mysqli_fetch_row($result)) {
                        printf("%s\n",$row[0]);
                    }
                    // Free result set
                    mysqli_free_result($result);
                }
            }
            while (mysqli_next_result($conn));

当我选择具有多个列表的多个用户时,我希望选择将其更新为“是”的任何内容,而不要重复其他条目。请以任何方式提供帮助。谢谢!

0 个答案:

没有答案