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: [Dave] Results link - min value in link

By rjbathgate - June 19, 2008

Hi Dave,

Thanks for the reply.

Without the commas, it does and doesn't work...

The prices set within the records DO have commas (i.e. displaying as 2,000,000). So when searching:

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

...because we're not using commas in the price_min in the link, it displays no results, because the results records DO have commas.

The commas work fine in a select search engine, for example:

<select name="price_min">
<option value="1,000,000">1,000,000</option>
</select>


We want to keep the commas in displayed records as otherwise we're loosing the neatness and style.

If the direct link won't work with commas, I guess I would need to build the direct link in as a form - a hidden <select> field (to take the price_min with commas) with a submit button which is just the link text - so there probably is a way around it, but not as easy or simple as a quick link...

Cheers
Rob

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