Results link - min value in link

5 posts by 2 authors in: Forums > CMS Builder
Last Post: June 19, 2008   (RSS)

By rjbathgate - June 19, 2008

Hi again,

I want a create a link (e.g. for a popular search) which displays results with a minimum price, but can't get it to work...

<p><a href="results.php?price=1,000,000">Property over &pound;1,000,000</a></p>
<p><a href="results.php?price_min=2,000,000">Property over &pound;2,000,000</a></p>


So in the above the first one simply gives me results when price is exactly 1,000,000... whereas the second (price_min_ doesn't work - just gives me all results.

The price_min works fine in my search engine, but not on this direct link.

Is there something i'm missing?

Thanks in advance,

Rob

Re: [rjbathgate] Results link - min value in link

By Dave - June 19, 2008

Hi Rob,

Try the numeric search ranges are picky - they don't understand commas. Try removing the commas from the link and let me know if that fixes it.

<p><a href="results.php?price_min=1000000">Property over &pound;1,000,000</a></p>
<p><a href="results.php?price_min=2000000">Property over &pound;2,000,000</a></p>

Dave Edis - Senior Developer
interactivetools.com

Re: [rjbathgate] Results link - min value in link

By Dave - June 19, 2008

Hi Rob,

There shouldn't be a difference between a text link and a form. So if you double check that and you're getting different results let me know.

Typically what you need to do is have only numeric values in the database and search values. It's a limitation of MySQL that in order to do numeric comparisons it needs no commas. You can prevent the entry of commas by using the field editor and making only "1234567890." allowed characters for the price field.

You can display the price formatted with commas (even if they're not in the database) by using the number_format() function. See this post for more details: http://www.interactivetools.com/iforum/P62471#62471

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Results link - min value in link

By rjbathgate - June 19, 2008

Ah ha, have figured it...

It works when there is just one comma, for example:

<p><a href="results.php?price_min=900,000">Property over &pound;900,000</a></p>

but not when there is more than one, for example:
<p><a href="results.php?price_min=2,000,000">Property over &pound;2,000,000</a></p>

So I think i'll resort to price being number only (no commas) and then using number_format() - more ability to restrict field entry in CMS too by just allow numbers.

Cheers for your help - strange how 1 comma works!

Rob