[wp-hackers] Please Help: How to compare 2 float values in meta_value column?

babyboy808 hi at eirestudio.net
Wed Feb 3 14:30:31 UTC 2010


Thanks for the reply (and others).

Unfortunetly that won't work as my problem is a little more complex.

Below is a piece of my code: 

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<?php
query_posts("category_name=$forwho&meta_value=$brand&paged=$paged&meta_compare=<=&meta_value=54");
?>


Adriaan Pelzer wrote:
> 
> Convert the meta_key strings to floats with a cast. Something like this:
> $price = (float) get_post_meta ($post->ID, "price", TRUE);
> 
> The value of price is now a float, and can be compared to your limits:
> if (($price > 23) && ($price < 41)) {
> ...
> }
> 
> Adriaan Pelzer
> PIT Productions
> +2712 651 2432
> 
> 
> On Wed, Feb 3, 2010 at 3:02 PM, babyboy808 <hi at eirestudio.net> wrote:
> 
>>
>> Hi Guys,
>>
>> I have about 100 posts in wordpress, all with a meta_key of price and a
>> value. How would I go about searching through all posts with a value
>> between
>> 23.00 and 41.00 for example?
>>
>> I know that 'meta_compare ' treats 'meta_value' as a string, so I can't
>> use
>> this to solve my problem.
>>
>> Anybody have any clues?
>>
>> Thanks
>> --
>> View this message in context:
>> http://old.nabble.com/Please-Help%3A-How-to-compare-2-float-values-in-meta_value-column--tp27435706p27435706.html
>> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
> 
> 

-- 
View this message in context: http://old.nabble.com/Please-Help%3A-How-to-compare-2-float-values-in-meta_value-column--tp27435706p27437166.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.



More information about the wp-hackers mailing list