dimanche 29 novembre 2015

PHP check boxes as boolean values

I need to create a Preferences table in a SQL using data from checkboxes. That is Pool,Jacuzzi, Backyard, Smart House are columns in Preferences that are TINYINTS to represent Boolean T or F. When a user checks a box, I want the value to be 1, else it stays at 0. So say a user wants a Pool and a Backyard and checks those two boxes. my $_POST[preferences] would be an array that would be [1,0,1,0].

<input type="checkbox" name="preferences[]" value="Pool"> Pool<br>
<input type="checkbox" name="preferences[]" value="Jacuzzi"> Jacuzzi<br>
<input type="checkbox" name="preferences[]" value="Backyard"> Backyard<br>
<input type="checkbox" name="preferences[]" value="Smart"> Smart House<br>




Aucun commentaire:

Enregistrer un commentaire