Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: help  (Read 2265 times)

HvGo D CB

  • Newbie
  • *
  • Karma: 0
  • Posts: 12
help
« on: December 07, 2006, 09:35:49 pm »

hi buddies...
i have a form with a checkbox...something like this..

                      echo "";
   while ($row = mysql_fetch_row($result)) {
   echo " ";
   if ($row['1']=='1'){
   echo " ";
   }else{
   echo " ";
   }
   echo "";
   }
the checkbox is checked if a field of my db is == '1'

this is ok!!

then i want to get the state of the chekboks generated and convert to true==1 and false==0 with a variable
call $esta

for ($i = 0; $i < mysql_fetch_row($result); $i++){
$getch=$_POST['chk'];

if ($getch == true){
$esta='1';
}else{
$esta='0';
}//end if
//echo $esta;
echo $esta;
}//end for

the problem is that there are checks that the state is false but  the var $esta print all '1'
Logged

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1717
    • http://www.snewscms.com
help
« Reply #1 on: December 07, 2006, 10:13:44 pm »

Try this:

Code: [Select]
if ( $_POST['chk'] ) {
     $esta='1';
}else{
     $esta='0';
}

echo $esta;
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
help
« Reply #2 on: December 07, 2006, 10:22:59 pm »

If you have a heap of checkboxes, EACH will need a different/unique name.
With each having the same name, your output would (I believe) all reflect whichever has the last setting.
Logged
Of all the things I have lost, it is my mind that I miss the most.
 

".$row['0']."".$row['0']."