URL parameter filters with where clauses

3 posts by 2 authors in: Forums > CMS Builder
Last Post: August 27, 2012   (RSS)

By InHouse - August 23, 2012

Hi,

Until recently I had a page which showed all the records for a given table. It also displayed a set of links which reloaded the same page but with parameters appented to the URL. i.e.:

mypage.php?type=blue

Then these links were fired the page would reload and display only the records where the type was 'blue'.

But now I have to put a where clause on the page at all times. It's working to limit the display of the original records but it also seems to stop the in-url filtering from working.

Any ideas of why that is, and how I can work around it?

Cheers,
J.

Re: [InHouse] URL parameter filters with where clauses

By Jason - August 24, 2012

Hi,

If you already have a value in the 'where' option, whatever you put in the URL will be appended to that where clause.

One thing you could do is to check to see if there is a value for "type" in the URL. If there is, don't set a where clause.

For example:

$where = "";

if (!@$_REQUEST['type']) {
$where = "put your where clause here";
}


You can then use $where in your where clause. If there's a value of type in the URL, $where will be blank, so just the automatic searching will occur.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/