Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用html表单在php循环中提交多个sql查询_Php_Html_Mysql - Fatal编程技术网

使用html表单在php循环中提交多个sql查询

使用html表单在php循环中提交多个sql查询,php,html,mysql,Php,Html,Mysql,我想使用准备好的语句和html表单提交多个sql查询。到目前为止,我将生成表单,每个表单都有自己的提交按钮。与数据库的连接和提交工作正常,但只提交按下按钮的表单数据 代码: $conn=newmysqli($servername、$username、$password、$database); $sql=“描述印度河咖啡;”; $result=mysqli\u查询($conn,$sql); $products=mysqli_fetch_数组($result)[0]。“”; while($row=m

我想使用准备好的语句和html表单提交多个sql查询。到目前为止,我将生成表单,每个表单都有自己的提交按钮。与数据库的连接和提交工作正常,但只提交按下按钮的表单数据

代码:

$conn=newmysqli($servername、$username、$password、$database);
$sql=“描述印度河咖啡;”;
$result=mysqli\u查询($conn,$sql);
$products=mysqli_fetch_数组($result)[0]。“
”; while($row=mysqli\u fetch\u数组($result)){ $insertedValues=$row[0]; 打印($insertedvalue)。“
”; ?>
$conn = new mysqli($servername, $username, $password, $database);

$sql = "describe indian_river_coffee;";
$result = mysqli_query($conn,$sql);
$products = mysqli_fetch_array($result)[0]."<br>";

while($row = mysqli_fetch_array($result)){
    $insertedValues = $row[0];
    print($insertedValues)."<br>";
    ?>
    <form action="#" method="POST">
    <input name="submit" type="number" id="submit" value="submit">
    <input name="button" type="submit" value="submit">
    </form>
    <?php
    if($stmt = mysqli_prepare($conn, "insert into 
    indian_river_coffee 
    (". $insertedValues .") values (?);")){


        mysqli_stmt_bind_param($stmt, "i", $_POST['submit']);
        mysqli_stmt_execute($stmt);
        mysqli_stmt_close($stmt);
    }
}