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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl/CGI-bin adjustment

Status
Not open for further replies.

jisoo22

Programmer
Apr 30, 2001
277
US
Hello!

Ok so here's the problem. I have a perl script that takes order info from a site, processes the quantity of the product(s) ordered as well as price totals and such. What I'm trying to do is to make it so that the first item they buy is regular price but every item after that is $4 off each. From the structure of the code, I believe the answer is to separate out all the ordered items into their own columns in a table-like format. Unfortunately I have a very hard time going about this, the vital part of the script is as follows:

foreach $row (@rows)
{
if (($rowcount == 0) && ($quantity{$rowcount} > 1))
{
print &quot;<tr><td width=$productw>$product{$rowcount}</td>\n&quot;;
print &quot;<td width=$pricew>$currency $price{$rowcount}</td>\n&quot;;
print &quot;<td width=$quanw><input type=\&quot;text\&quot; name=\&quot;quan-$rowcount\&quot; SIZE=\&quot;5\&quot; MAXLENGTH=\&quot;5\&quot; value=\&quot;1\&quot;></td>\n&quot;;
$thispricedec=$price{$rowcount};
$thisprice = sprintf (&quot;%.2f\n&quot;, $thispricedec);
print &quot;<td width=$totalw>$currency $thisprice</td>\n&quot;;
print &quot;<td width=$deletew><input type=\&quot;checkbox\&quot; name=\&quot;del-$rowcount\&quot;></td>\n&quot;;
print &quot;</tr>\n&quot;;
$totalprice=$totalprice+$price{$rowcount};
#$quantity($rowcount) = $quantity($rowcount)-1;
print &quot;<tr><td width=$productw>$product{$rowcount}</td>\n&quot;;
print &quot;<td width=$pricew>$currency ($price{$rowcount}-4)</td>\n&quot;;
print &quot;<td width=$quanw><input type=\&quot;text\&quot; name=\&quot;quan-$rowcount\&quot; SIZE=\&quot;5\&quot; MAXLENGTH=\&quot;5\&quot; value=\&quot;($quantity{$rowcount}-1)\&quot;></td>\n&quot;;
$thispricedec=(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$thisprice = sprintf (&quot;%.2f\n&quot;, $thispricedec);
print &quot;<td width=$totalw>$currency $thisprice</td>\n&quot;;
print &quot;<td width=$deletew><input type=\&quot;checkbox\&quot; name=\&quot;del-$rowcount\&quot;></td>\n&quot;;
print &quot;</tr>\n&quot;;
$totalprice=$totalprice+(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$rowcount=$rowcount+1;
}
else
{
print &quot;<tr><td width=$productw>$product{$rowcount}</td>\n&quot;;
print &quot;<td width=$pricew>$currency ($price{$rowcount}-4)</td>\n&quot;;
print &quot;<td width=$quanw><input type=\&quot;text\&quot; name=\&quot;quan-$rowcount\&quot; SIZE=\&quot;5\&quot; MAXLENGTH=\&quot;5\&quot; value=\&quot;($quantity{$rowcount}-1)\&quot;></td>\n&quot;;
$thispricedec=(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$thisprice = sprintf (&quot;%.2f\n&quot;, $thispricedec);
print &quot;<td width=$totalw>$currency $thisprice</td>\n&quot;;
print &quot;<td width=$deletew><input type=\&quot;checkbox\&quot; name=\&quot;del-$rowcount\&quot;></td>\n&quot;;
print &quot;</tr>\n&quot;;
$totalprice=$totalprice+(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$rowcount=$rowcount+1;
}
}


I gave it my best shot but it doesn't work. Can someone help me?

Thanks,
Jisoo22
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top