CodeIgniter Forums
Pagination & Storing Query Stings from array of POST value - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Pagination & Storing Query Stings from array of POST value (/thread-47679.html)



Pagination & Storing Query Stings from array of POST value - El Forum - 12-18-2011

[eluser]Unknown[/eluser]
I am following nettut+ tutorial for pagination and to store POST inputs as querystrings in db. So far, everything works fine until, suppose if I get an array as POST input, i am unable to loop through it and get all the array values and to store into query_array (i.e., store array within array).

The snippets below:

Code:
$query_array = array(
‘gender’ => $this->input->post(‘gender’),
‘minage’ => $this->input->post(‘minage’),
‘maxage’ => $this->input->post(‘maxage’),
‘Citizenship’ => $this->input->post(‘citizenship’), // checkboxes with name citizenship[]
);

This returns only last stored array value in Citizenship.

The output array:
Code:
Array ( [gender] => 1 [minage] => 18 [maxage] => 24 [Citizenship] => 2 )

makes the query string as:

Code:
&gender=1&minage=18&maxage=24&Citizenship=2

But, my requirement is to get all the values of ‘Citizenship’ array instead of last stored value.

The output required to make query string:

Code:
Array ( [gender] => 1 [minage] => 18 [maxage] => 24 [Citizenship] => 2 [Citizenship] => 4 [Citizenship] => 6 )

The query string :

Code:
&gender=1&minage=18&maxage=24&Citizenship;[]=2&Citizenship;[]=4&Citizenship;[]=6


Any help appreciated.

Thanks