I have two array name position and data respectively.
$position = array("A1","A2","A3","A4","A5","B1","B2","B3","B4","B5");
Array ( [0] => B1 [1] => B2 [2] => A2 [3] => A3 )
this second array named data which are coming from mysql database.Now i need to check the element of data array in position array.I tried this code
for ($i=0; $i < 10 ; $i++) { if ($i==5){?>
<br> <?php } ?>
<input type="checkbox" name="pos[]" value="<?php echo $position[$i];?>"
<?php if(in_array($data[$i], $position)) echo "checked";
?>>
<label ><?php echo $position[$i] ?></label>
<?php }
and i get the result is
A1 A2 A3 A4
Notice: Undefined offset: 4 in G:\xampp\htdocs\library\ajax.php on line 25 A5
Notice: Undefined offset: 5 in G:\xampp\htdocs\library\ajax.php on line 25 B1
Notice: Undefined offset: 6 in G:\xampp\htdocs\library\ajax.php on line 25 B2
Notice: Undefined offset: 7 in G:\xampp\htdocs\library\ajax.php on line 25 B3
Notice: Undefined offset: 8 in G:\xampp\htdocs\library\ajax.php on line 25 B4
Notice: Undefined offset: 9 in G:\xampp\htdocs\library\ajax.php on line 25 B5
Thanks in advance