Welcome Guest, Not a member yet? Register   Sign In
query problem
#1

[eluser]elmne[/eluser]
I'm running the query below

Code:
function view_all_customertype()
    {
       $this->record_status = $this->input->post('record_status');
        
         if ($this->record_status = "active")
        {
           $query = $this->db->query("SELECT customer_type_id, customer_type, record_status FROM customer_type WHERE record_status ='active' ");
         }
         else if ($this->record_status = "inactive")
         {
            $query = $this->db->query("SELECT customer_type_id, customer_type, record_status FROM customer_type WHERE record_status ='inactive' ");
         }
         else
         {
            $query = $this->db->query("SELECT customer_type_id, customer_type, record_status FROM customer_type");
         }

        return $query;
        
    }


I do not get an output.

But when i run this line only

Code:
$query = $this->db->query("SELECT customer_type_id, customer_type, record_status FROM customer_type");

I get an output. What's the cause?

If i call this function without a post parameter to pass on, does it make a difference? since the function can be called by a view with or without a form. Views that need to display specific records as active or inactive, would use a form field to submit the record_status

and views that just needed to show everything without a user having to select inactive or active, would just use a link to the controller which in turn loads the class and function
When a loop is done through the "if" statement, it would end up running the last one which is the default if neither active or inactive qualify which would be teh case with just a link to the controller as no form has been used to select "active or inactive" so no form value is posted.
#2

[eluser]benurv[/eluser]
if ($this->record_status = "active") should be if ($this->record_status == "active")
#3

[eluser]elmne[/eluser]
Thanks




Theme © iAndrew 2016 - Forum software by © MyBB