Welcome Guest, Not a member yet? Register   Sign In
Pagination & Storing Query Stings from array of POST value
#1

[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




Theme © iAndrew 2016 - Forum software by © MyBB