multiple values insertion of checkbox only last value is taking in database

后端 未结 3 1137
自闭症患者
自闭症患者 2021-01-15 19:33

I need to insert more than one values in checkbox but now it is seemed to be only the last value am entering is inserting to database.

this is my HTML code

3条回答
  •  悲&欢浪女
    2021-01-15 20:23

    If i understand your problem you are looking for something like this:-

    $array= array(
    '0' => 123,
    '1' => 456,
    '2' => 789, 
    ); // this is your post product array oryou want to get last value of that arrray
        -----Or----
    $array = $_POST['product']; // your post data after submission
    
    end($array);         // move the internal pointer to the end of the array
    $key = key($array);  // fetches the key of the element pointed to by the internal pointer
    echo $array[$key]; // 789
    

    Hope it helps!

提交回复
热议问题