通过条件> =或<=在2个数字字段之间更改TD背景颜色[重复]

Possible Duplicate:
Can I change the <td> background if a field result is great or equal to another field?

Trying to get my script to work, displaying mySQl results in an HTML table via php with a particular column TD that contains $qty that needs to have its background turn red when it equals or passes $min or $max.

Maybe there's a better way to right this php?

Script is not working.

<script type="text/javascript">
$(document).ready(function() {
var min = parseInt($('.min').text());
var max = parseInt($('.max').text());
var qty = parseInt($('.quantity').text());

if (qty >= max || qty <= min ) {
$('.quantity').css('background-color', 'red');
} 
});
</script>

My php table / the three fields are toward the end of the table:

$o .= '<tr><td>'.$type.'</td><td>'.$part_no.'</td><td>'.$description.'</td><td>'.$artwork.' &nbsp; &nbsp;</td><td><a href="/data/hero/copies/'.$part_no.'.pdf" target="_blank">Link &nbsp;</a></td><td align=right class="min">'.number_format($min).'</td><td align=right class="max">'.number_format($max).'</td><td align=right class="quantity">'.number_format($qty).'</td></tr>';}

Your php sample has a stray } at the end of the line. Is that causing this issue?

I've just tried this with the javascript you posted and this php:

$o = '<tr><td>'.$type.'</td><td>'.$part_no.'</td><td>'.$description.'</td><td>'.$artwork.' &nbsp; &nbsp;</td><td><a href="/data/hero/copies/'.$part_no.'.pdf" target="_blank">Link &nbsp;</a></td><td align=right class="min">'.number_format($min).'</td><td align=right class="max">'.number_format($max).'</td><td align=right class="quantity">'.number_format($qty).'</td></tr>';

It works perfectly.

Is $o getting properly printed out to the browser? If you view the HTML source, do you have a tds with the classes min, max and quantity? What exact symptoms of it not working do you get? Maybe you could post a little more of the script?