+ 4

checkbox

Good day! Task: there is a loop in which are formed checkbox's from 1 to 254. It is necessary to establish "tick" on a given array. For example: $_GET=[5=>5, 6=>6, 7=>7, 8=>8]; for($i=1;$i<255;$i++){ foreach($_GET as $get){ if($i==$get){ echo "$i<br/><input type='checkbox' name='$i' value='$i' checked/>"; }else{ echo "$i<br/><input type='checkbox' name='$i' value='$i'/>"; } } }

20th Oct 2017, 2:39 AM
Пешков Павел
Пешков Павел - avatar
3 Respostas
+ 22
nice.. transilation @calvin
14th Oct 2017, 8:06 AM
Genes Sambayena
Genes Sambayena - avatar
+ 5
GT: "checkbox Good afternoon! Task: there is a loop in which checkboxes are formed from 1 to 254. It is necessary to set "checkboxes" for them in the given array $ array = [5 => 5, 6 => 6, 7 => 7, 8 => 8] . // This script is needed to select the range of IP addresses. "
13th Oct 2017, 5:08 AM
Calviղ
Calviղ - avatar
0
While you're here to put each other likes, I found the solution!!! <?php error_reporting('E_ALL'); $array=[11=>11,12=>12,13=>13,14=>14]; for($i=1;$i<=254;$i++) { if($i==$array[$i]) { $checked='checked'; } else { $checked=''; } echo "$i<input type='checkbox' name='$i' $checked/>"; } ?>
20th Oct 2017, 1:31 PM
Пешков Павел
Пешков Павел - avatar