+ 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 Answers
+ 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