CodeIgniter Forums
passing query results from view page to controller. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: passing query results from view page to controller. (/showthread.php?tid=56575)



passing query results from view page to controller. - El Forum - 01-03-2013

[eluser]soyut[/eluser]
Hello,

I have built a search page. I enter some criteria and when i click the submit it runs a controller function then shows all the query results below(using "foreach").
However, I created an anchor link below the results table, and when you click that it runs the different function of the same controller. Problem is here. Somehow, I cant manage to put this query results of the search page to anchor link and pass it to the another function in the controller.

How can i pass this query results to another controller using anchor link?

Thanks in advance.


passing query results from view page to controller. - El Forum - 01-03-2013

[eluser]jprateragg[/eluser]
If you want to pass the query results of your search to the anchor function, you'll have to convert the results to a string, then pass the string to the anchor function.

Code:
$s = '';
foreach($data as $key => $value)
{
    //your code that formats/displays the search results
    $s .= 'a[]='. $value->field1 .'&b[]='. $value->field2 .'&c[]='. $value->field3;
}

This will convert your results into a string and allow you to pass the results to another page. However, it may be easier to create a private function that performs the search, pass the search parameters to your anchor function, then simply perform a new search on the new page using the private search function.