html - Multiple checkboxes with one name (no jquery!) -


i have following list of checkboxes:

<input type="checkbox" name="day_of_week" value="1">monday <input type="checkbox" name="day_of_week" value="2">tuesday <input type="checkbox" name="day_of_week" value="3">wednessday <input type="checkbox" name="day_of_week" value="4">thursday <input type="checkbox" name="day_of_week" value="5">friday <input type="checkbox" name="day_of_week" value="6">saturday <input type="checkbox" name="day_of_week" value="7">sunday 

after user submits full form, receive in file:

$week_days = mysqli_real_escape_string($this->db->conn_id, $_post['day_of_week']) 

but $week_days contains value of last checked checkbox, not of them. how can receive values?

the name should array.

<input type="checkbox" name="day_of_week[]" value="1">monday <input type="checkbox" name="day_of_week[]" value="2">tuesday <input type="checkbox" name="day_of_week[]" value="3">wednessday <input type="checkbox" name="day_of_week[]" value="4">thursday <input type="checkbox" name="day_of_week[]" value="5">friday <input type="checkbox" name="day_of_week[]" value="6">saturday <input type="checkbox" name="day_of_week[]" value="7">sunday 

hope helps.


for second error, mysqli_real_escape_string accepts second parameter string , passing array. please check this

string mysqli_real_escape_string ( mysqli $link , string $escapestr ) 

please use loop solve error.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -