Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.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
Php 数组计数在我的窗体中不起作用_Php_Mysql_Arrays - Fatal编程技术网

Php 数组计数在我的窗体中不起作用

Php 数组计数在我的窗体中不起作用,php,mysql,arrays,Php,Mysql,Arrays,数组计数在我的窗体中工作不正常。。我克隆了输入值 请检查此链接中的全部代码 下面是php代码 if(isset($\u POST['Submit'])){ echo$cnt=count($\u POST['task\u description']);//die(); 对于($i=0;$i请验证: 两个文本框都至少包含一些值 两者形式相同 您希望得到什么?您是否收到错误消息?打印错误($con)的输出是什么如果您在调用mysqli\u查询后运行它,请参见我编辑的问题…即第二个数组值未插入…@Tom

数组计数在我的窗体中工作不正常。。我克隆了输入值

请检查此链接中的全部代码

下面是php代码

if(isset($\u POST['Submit'])){
echo$cnt=count($\u POST['task\u description']);//die();
对于($i=0;$i请验证:

  • 两个文本框都至少包含一些值
  • 两者形式相同

  • 您希望得到什么?您是否收到错误消息?打印错误($con)的输出是什么
    如果您在调用
    mysqli\u查询后运行它,请参见我编辑的问题…即第二个数组值未插入…@Tom No..第一个数组记录已插入..但第二个数组未插入我们能看到整个
    吗?
    if(isset($_POST['Submit'])) {
         echo $cnt = count($_POST['task_description']);  //die();
    
    for($i=0;$i<$cnt; $i++ ){
        mysqli_query($con,"INSERT INTO ts_task(project,task_title,task_description,minutes,created_date,status)VALUES('".$_POST['project'][$i]."','".$_POST['task_title'][$i]."','".$_POST['task_description'][$i]."','".$_POST['minutes'][$i]."','".date('Y-m-d')."','".$_POST['status'][$i]."')");
      }
    
    header("Location:tasklist.php");    
    die();
    }
    
     First Array
     <input name="task_title[]" class="form-control"  type="text"  style="width:150px;">
     <input class="form-control"  type="text" name="task_description[]" style="width:150px;">
     <input class="form-control"  type="text" name="project[]" style="width:150px;">
     <input class="form-control"  type="text" name="minutes[]" style="width:150px;">
    
    Second Array
    <input name="task_title[]" class="form-control"  type="text"  style="width:150px;">
     <input class="form-control"  type="text" name="task_description[]" style="width:150px;">
     <input class="form-control"  type="text" name="project[]" style="width:150px;">
     <input class="form-control"  type="text" name="minutes[]" style="width:150px;">