PHP : insert multiple check boxes values into one MySQL column

前端 未结 5 1888
余生分开走
余生分开走 2020-12-14 13:30

I want to write a simple PHP function to insert values of 10 and 20 check boxes. Now, the issue is: should I insert all values in a single column of MySQL table or should I

5条回答
  •  有刺的猬
    2020-12-14 14:12

    Firstly very straight to point, I prefer doing names like this from different checkboxes

    BasketBall;Cricket;Tennis
    

    You can do that by

    implode(";",$array);
    

    and then write that in mySQL table...

    To get those values Just use

    $array = explode(";",$urVariable);
    

    For different values use

    numberOne = $array[1]; // returns Cricket
    

    to change any value use Just get the values and rewrite in ";" form..

    I like this as it is simple to implement and do job perfectly!

提交回复
热议问题