0

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

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by haru-chan
0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.