获取错误数组进行字符串对话

时间:2019-02-16 07:37:17

标签: php arrays string-conversion multiple-insert

我想使用添加按钮插入多个数据,而没有插入动态添加的按钮的数据有时会变为0,有时只是没有变化...

include 'config.php';

if(isset($_POST['submit1'])) {
    $bill_no = isset($_REQUEST['bill_no']) ? $_REQUEST['bill_no'] : '';
    $bill_date = isset($_REQUEST['bill_date']) ? $_REQUEST['bill_date'] : '';

    $proselect = isset($_REQUEST['proselect']) ? $_REQUEST['proselect'] : '';

    $price = isset($_REQUEST['price']) ? $_REQUEST['price'] : '';

    $addItem = isset($_REQUEST['Add1']) ? $_REQUEST['Add1'] : '';
    $check  = "SELECT bill_no from bill_p where bill_no = '$bill_no'";
    $result = mysqli_query($conn,$check);
    $count1 = mysqli_fetch_array($result);

    if ($count1 > 0) {
        echo '<script text="javascript/text">alert("Bill Exist")</script';
    }
    else
    {
        $count = count($REQUEST['price']);

        for($i = 0; $i <= $count; $i++)
        {
            $bill_no = $REQUEST['bill_no'][$i];
            $bill_date = $REQUEST['bill_date'][$i];
            $proselect = $REQUEST['proselect'][$i];
            $price = $REQUEST['price'][$i];

            $query = "INSERT INTO bill_p(p_id,bill_no,b_date,amount) VALUES ('$proselect','$bill_no','$bill_date','$price')";   

            $exe = mysqli_query($conn, $query);

0 个答案:

没有答案