1

This code is in model... i want to return these two values in controller.....please help me if you know

Array ( [disease_name] => magraines ) Array ( [disease_name] => brain cancer )

when i do

return print_r($qq);

then i get one value but i need two value that one value is

Array ( [disease_name] => magraines ) 1

function getDiseaseInfo()
{


             $spytoms = $_GET['syptoms'];

            foreach ($spytoms as $ss) 
                {
                    $query = $this->db->query("SELECT d.disease_name FROM diseases d,syptoms s ,syptoms_disease sd
                        WHERE 
                        '$ss' = s.syptom_name  AND
                        s.s_id = sd.s_id_fk 
                        AND sd.d_id_fk IN (d.d_id)
                        ");
                    $qq = $query->row_array();
                    print_r($qq);
                }


}

1 Answer 1

1

From your model return $qq only.

you are returning return print_r($qq) thats not the correct way.

print_r will print the entire array.

if you want to return your array values to your controller you have to return it like return $qq;

Update 1

I think you are getting last row's values,if im right you have to follow below steps,

You have to introduce a new array variable above your foreach

and assign your query array values to this newly created array

and you have to return that newly created array

function getDiseaseInfo() 
    { 
        $spytoms = $_GET['syptoms']; 
        $tmpArray = array();
        foreach ($spytoms as $ss) 
            { 
                $query = $this->db->query("SELECT d.disease_name FROM diseases d,syptoms s ,syptoms_disease sd WHERE '$ss' = s.syptom_name AND s.s_id = sd.s_id_fk AND sd.d_id_fk IN (d.d_id) "); 
                $qq = $query->row_array(); 
                $tmpArray[] = $qq;
            } 
            return $tmpArray; 
    } 
Sign up to request clarification or add additional context in comments.

4 Comments

bro i want to return entire row and i want to send entire row to controller
function getDiseaseInfo() { $spytoms = $_GET['syptoms']; foreach ($spytoms as $ss) { $query = $this->db->query("SELECT d.disease_name FROM diseases d,syptoms s ,syptoms_disease sd WHERE '$ss' = s.syptom_name AND s.s_id = sd.s_id_fk AND sd.d_id_fk IN (d.d_id) "); $qq = $query->row_array(); } return $qq; }
@NadirAlyani you are welcome. mark this answer as accepted answer by clicking the tick sign if you are satisfied with the answer. :)
Thanks for the feedback! Votes cast by those with less than 15 reputation are recorded, but do not change the publicly displayed post

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.