+ 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'/>"; } } }
3 Answers
+ 22
nice.. transilation @calvin
+ 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. "
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/>";
}
?>