Welcome Guest, Not a member yet? Register   Sign In
can I return 2 sets of results from 2 different talbes from one function? if yes- how to?
#5

[eluser]zoreli[/eluser]
[quote author="boltsabre" date="1340103802"]
You're returning either return array(); if no results were found, or $post_array;. This code will NEVER check $post_query2 as you are returning something before you get to it.
I'm not 100% sure what you're trying to achieve, but you could try something like this perhaps...???

Code:
if ($post_query->num_rows() == 0) {
    $return['post_q_1_empty'] = true;
    $return['post_q_1_full'] = false;
} else {
    $i = 0;

    foreach ($post_query->result() AS $row) {
        ...;
    }
    $return['post_q_1_empty'] = false;
    $return['post_q_1_full'] = $post_array;
}
if ($post_query2->num_rows() == 0) {
    $return['post_q_2_empty'] = true;
    $return['post_q_2_full'] = false;
} else {
    $a = 0;

    foreach ($post_query2->result() AS $row2) {
        ...
        $a++;
    }
    $return['post_q_2_empty'] = false;
    $return['post_q_2_full'] = $post_array2;
}
return $return
Basically you're just building your multiple return values into an array, and returning that array.

Hope that helps...???[/quote]

You nailed the problem, now I need to find the solution.

After commenting the part for the first query I dump the var_dump($post_array2);
die();
I get the result for the user. My result was displayed.

So I have to find the way how to implement the code that you posted above. For some reason the first time I make an attempt I get million error messages. I will now try again and post the errors here.

Regards,Zoreli


Messages In This Thread
can I return 2 sets of results from 2 different talbes from one function? if yes- how to? - by El Forum - 06-19-2012, 09:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB