Inserting checkbox values into database

前端 未结 6 1370
醉梦人生
醉梦人生 2020-12-10 23:39

I need help for this problem that i\'m trying to solve for a while (i\'m new in PHP). I have a form with several checkboxes which values are pulled from a database. I manage

6条回答
  •  [愿得一人]
    2020-12-11 00:00

    This is the loop that I needed. I realized that I need a loop through each key with the $i variable.

    if(isset($_POST['id_dodatoci'])){
        $id_dodatoci=$_POST['id_dodatoci'];
        $arr_num=count($id_dodatoci);
        $i=0;
        while ($i < $arr_num)
        {
            $query="INSERT INTO `dodatoci_hotel`(id_dodatoci,info_id) 
                VALUES ('$id_dodatoci[$i]','$info_id')";
            $res=mysql_query($query) or die('ERROR INSERTING: '.mysql_error());
            $i++;
        }
    }
    

提交回复
热议问题