Welcome Guest, Not a member yet? Register   Sign In
How do i check if table item is either true or false
#2

Hi,

I am not certain what the correct thing is here, but I always store a 1 or a 0 in a tinyint(1) field for true or false. Then I check the value to see if it is a 1 or not. So the way you are going about it seems right to me.

How you deal with that is up to you, depending on what you want to achieve. You could have a checkbox that is checked or not depending on the 'active' result, or you could output two different buttons, one for 'make active' and one for 'make inactive'. Or you could hide everything about your post form with a 'This post is currently disabled message'.

To manage the 'make active' button in your controller, just send a value to the controller that is otherwise set to FALSE,

Something like...
PHP Code:
class Blog_post extends CI_Controller {

 
 public function view($make_active=FALSE)
 
 {
 
     .......

 
     if ($make_active == 1)
 
     {
 
         ... do whatever
      
}

 
     ......
 
 }



Or if you are doing it in a form, check the value of the post field and if it is set to the right value toggle the database value for that field.

There are so many ways to do what you are asking, I cannot really add any more.

Hope that helps in some way,

Paul
Reply


Messages In This Thread
RE: How do i check if table item is either true or false - by PaulD - 02-11-2016, 10:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB