jac.kock Posted September 16, 2012 Share Posted September 16, 2012 hi all, i want to run in my cms a script that can set up or remove a user_block. what i have so var will set 1 tot the database but i cant seem to return it to 0, so i hope that someone will help me to solve it! code so var: // this function is called in a form with while(ect....) <checkbox id='[b]' value='$user_id'> for more than one user //set blokkeren function set_blok($blk) { foreach($blk as $var) { if($blk[$a]=='') { $set='0'; } else { $set='1'; } //this i tryed to see if it needs to be 0 or 1 $sql="update users set blokkeren='$set' where user_id='$var'"; $res=mysql_query($sql); } if(!$res) { return false; } else { return true; } } Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 16, 2012 Share Posted September 16, 2012 What is $a? Quote Link to comment Share on other sites More sharing options...
jac.kock Posted September 16, 2012 Author Share Posted September 16, 2012 hi, $a was for a test i did i used it like: function set_blok($blk) { foreach($blk as $var;$a=$a++) { if($blk[$a]=='') { $set='0'; } else { $set='1'; } //this i tryed to see if it needs to be 0 or 1 $sql="update users set blokkeren='$set' where user_id='$var'"; $res=mysql_query($sql); } if(!$res) { return false; } else { return true; } } i tryed to get each $blk array i want when i uncheck the box that it set it to 0 en by checked to 1 can you help me? thnx Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 16, 2012 Share Posted September 16, 2012 In your code in your first post, there is no $a. So you will always be setting $set = 0. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.