Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

between 2 values search problem

Status
Not open for further replies.

oshjosh

Technical User
Mar 11, 2002
34
0
0
TH
Hi I am using a small cgi program to open a flat data file then go through the results and display only results that are between two values in a field.
I have pasted the part of the script that I am using to do this below:

The field I am trying to use tha value of is $price, my problem is that it works fine for 2 digit numbers, if $price is 20 and I set the values in my program to 1 and 30 I get the results I want, howeber I need to do this using upto 6 digit numbers in $price.. if I currently change my values in the search program to 1 & 201, it gives me incorrect results as I think it is only looking at the first 2 digits of the number. Can anyone assist please I am a novice with this and am OK at cutting and pasting to get scripts to work but thats about as far as it goes.

Thanks Rob

Here is the snipet of code that looks at the value of price then prints the results dependant on the value:

foreach $data (@data) {
($id,$simage,$bimage,$Category,$itemcode,$price,$Sex,$Size,$new,$Description,) = split(/::/, $data);
if (($price gt 1) && ($price lt 200)) {
$a++;
if ($a <= $line) {
next;
}
else {
$i++;$j++;
if ($j <= 9) {
if ($i==1) {
print &quot;<tr>&quot;;
}

 


$price *= 1; #force numeric
if($price >1 && 200 > $price)
vox clamantis in deserto.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top