I have a string that should control if the checkbox array is checked or not when i open the page...
I made a string which contain a value of 0 & 1 and deal with the string as an array
if 1=checked

note: I retreive my checkbox values from the database

<?
do{
?>
<tr>
<td><? $cost=$temprow3['cost'];?>

<input type="checkbox" name="pro[]" value="<? echo $cost;?>" <?php
$OK = isset($_POST['pro']);

if ($OK && in_array($cost, $_POST['pro'])) { ?>
checked="checked" <? $spec .="1"; ?>
<?php } else {$spec .="0"; } ?>
<? if($m != " "){
$my=strlen($m);
for ($i=0; $i<$my; $i++)
{

if( $m[$i] ==1 ){

?>
checked="checked" <? }}}?>

/>

<? echo ($temprow3['name']); ?> </td>
<td><? echo $cost;?> </td>
</tr><?
}while($temprow3 = $adb->fetch_array($result3));?>

the function of the String:

<? if($m != " "){
$my=strlen($m);
for ($i=0; $i<$my; $i++)
{

if( $m[$i] ==1 ){

?>
checked="checked" <? }}}?>

$m is the String, if the String is not empty, enter the String and see if 1 checked=checked

its not seem to work so if someone know a thing I can do please help

in your empty strings, you have a space. why is that? or is that the error.

example:

if($m != " "){

should be:

if($m != ""){

if you want to see if its empty.

thanx for the reply...

tried it in both ways and it did the same effect I even replaced it with null but still nothing worked

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.