pagination php mysql
am 19.10.2008 13:53:52 von ron
Hi,
I am implementing pagination on my php script, pagination is already
working, the result is displayed as checkboxes for users to check their
choices. my prob is if i have more than 1 page, users should be able to
choose from all 4 pages,
e.g. result is about 4 pages, user can choose up to 10 of the total
results. user chose 3 option on page 1, 3 option on page 2, 2 on page 3
and 2 on page 4. how can i get the values from page 1 2 and 3 so i cn
insert it on the database?
Hope i am not confusing. TIA
Regards,
Ron
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: pagination php mysql
am 20.10.2008 02:38:25 von Vicente
> I am implementing pagination on my php script, pagination is already
> working, the result is displayed as checkboxes for users to check their
> choices. my prob is if i have more than 1 page, users should be able to
> choose from all 4 pages,
one solution is creating a temporal table, which can be re-created and
dropped when starting and ending the user session (table name can be
an unique_ID). Then, the checkbox selections are inserted, deleted,
etc.. with mysql_functions every time the user change every page.
Another solution is adding the ID of every selected checkbox to a
cookie or session variable in format 1,5,42,87,412... etc. Then you
can manage the selections changes by reading the array elements using
a for... when the user change every page:
$foo = array_unique($foo); // checkbox selections
if (count($foo) > 0) {
// loop through the array of selections
for ($i=0;$i
// read and write the session_var to update, delete, etc..
if (eregi($foo[$i], $session_var)) { // if exists ...etc
}
//...
}
}
When the user ends, you will have a temporal table or a session
variable with all his checkboxes selected.
First method is slower but more secure. Second is speediest but it can
have more failures because are session vars or cookies. It depends of
your control errors and also the visits profile.
Hope it helps,
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: pagination php mysql
am 22.10.2008 02:58:53 von Fergus Gibson
On Sun, Oct 19, 2008 at 5:38 PM, wrote:
[...]
> First method is slower but more secure. Second is speediest but it can
> have more failures because are session vars or cookies. It depends of
> your control errors and also the visits profile.
I'm not sure what you're trying to say here. There shouldn't be any
errors in session variables and sessions needn't rely on cookies for
propagation, that's just the default configuration. It's true that
sessions can be hijacked, but the danger is slight and easily
mitigated. The round trips on the database for your alternative
scheme would be terribly unscalable.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: pagination php mysql
am 31.10.2008 09:13:51 von Goltsios Theodore
--------------040507090504060307020602
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
>> I am implementing pagination on my php script, pagination is already
>> working, the result is displayed as checkboxes for users to check their
>> choices. my prob is if i have more than 1 page, users should be able to
>> choose from all 4 pages,
>>
>
> one solution is creating a temporal table, which can be re-created and
> dropped when starting and ending the user session (table name can be
> an unique_ID). Then, the checkbox selections are inserted, deleted,
> etc.. with mysql_functions every time the user change every page.
>
And how do you suggest that the data will be kept when the user goes to
page 2?
The session will end and the temporary table will be destroyed. So this
is probably not so wise don't you think ?
> Another solution is adding the ID of every selected checkbox to a
> cookie or session variable in format 1,5,42,87,412... etc. Then you
> can manage the selections changes by reading the array elements using
> a for... when the user change every page:
>
> $foo = array_unique($foo); // checkbox selections
> if (count($foo) > 0) {
> // loop through the array of selections
> for ($i=0;$i
>
> // read and write the session_var to update, delete, etc..
> if (eregi($foo[$i], $session_var)) { // if exists ...etc
>
> }
> //...
>
> }
> }
>
Cookie is a good choice although if the checkboxes are many your cookie
will grow. Your problem here is how you can maintain data between pages
in order to keep all the users options. This problem has many solutions:
cookies, sessions, memcache, database etc.
The problem that you will a mechanism that will control the data.
> When the user ends, you will have a temporal table or a session
> variable with all his checkboxes selected.
>
Oh now I get it !! by temporary table you don't really mean a temporary
table like that:
http://archive.devwebpro.com/devwebpro-39-20010817Temporary- Tables-With-MySQL.html
but a table you will not use permanently. But AFAIK changing schema is
bad practice. Why not just keep the table and use it for this use?
> First method is slower but more secure. Second is speediest but it can
> have more failures because are session vars or cookies. It depends of
> your control errors and also the visits profile.
>
>
I wouldn't bet on that I think it depends on the case.
> Hope it helps,
>
>
>
--
Thodoris
--------------040507090504060307020602--