Forum Moderators: coopster

Message Too Old, No Replies

Previous and Next Links

With PHP/MySQL

         

knighty

5:30 pm on Feb 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've found plenty of tutorials on how to do the old next/previous links

However, they only work on simple queries.

I have four possible queries depending on who is logged in and when the page might not run any queries.

For Example..

Lets say I have a table called drinks the user selects the varios options of the search such as price, wether its in a bottle or can etc.

If the person running the query is logged in as a barman the results would only return alcoholic drinks, a kid would only get soft drinks etc. (there are also many other variables in the query which may be present)

I want to be able to have the next link to bring up the next 10 results but at the moment I have to either pass the entire query through in the link or filter the results through and run the query again.

Is there a better way to do this...its just that the code seems very messy.

If Could just refesh the page with the new LIMIT $start, $end that would be great :)

andreasfriedrich

5:37 pm on Feb 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



knighty [webmasterworld.com] wrote at 05:30 on Feb. 06, 2003 in message #1 [webmasterworld.com]
is logged in

I guess thatīs your answer. Iīd use the session to store the different parameter.

Andreas

jatar_k

5:40 pm on Feb 6, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



yep, looks like your best choices are the session or a cookie.

knighty

10:22 am on Feb 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK...

So how would I go about that? I already use cookies to detect the type of person logged in within the query anyway.

I guess just move the 4 possible queries that could be run to the top of the page (so I can set a cookie) and then either...

[A] set one cookie called search with each value passed through from form and then reasemble those values to form one select statement?

[B]just pass through the select statement into the cookie and use that? (but how to change LIMIT in the passed select statement?)

jatar_k

6:55 pm on Feb 7, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



A sounds the best, crunch the vars you need together and then serialize [php.net] them. Then you can reconstruct the query when you need to.