Monday 15 June 2015

html - saving multiple checkbox to database in PHP -



html - saving multiple checkbox to database in PHP -

i having problem in printing values of different checkbox same name & different values..

php

//$infect_type=array(); $infect_type = isset($_post['infect_type']) ? $_post['infect_type'] : null; $values= implode(",",$infect_type); print_r($values);

html

<input type="checkbox" name="infect_type" value="blood born" /> <input type="checkbox" name="infect_type" value="air born" />

i can value selected lastly before submitting.

use array notation checkboxes names:

<input type="checkbox" name="infect_type[]" value="blood born" /> <input type="checkbox" name="infect_type[]" value="air born" />

in case $_post['infect_type'] going array of checked values.

php html

No comments:

Post a Comment