Hi everyone,
I am a biginner to PHP and I've tried to write code for online store. I got problem with the summing of variables where the sum is correct only if the value less than 1000, but when the sum value more than 1000, it gives wrong answer such as if the summation value is 1,200, the answer given is only 1 but if the summation value is 120, the answer is correct 120. It is kind of weird, because the summation is actually works..Please anybody can help, I would appreciate very much...
Here is the code...
<table align="center">
<td>
<table border="1" align="left" cellpadding="5">
<tr>
<td>Quantity</td>
<td>Item Image</td>
<td>Item Name</td>
<td>Price Each</td>
<td>Unit</td>
<td>Extended Price</td>
<td></td>
</tr>
<?php
$sessid = session_id();
$query = "SELECT * FROM carttemp WHERE carttemp_sess = '$sessid'";
$results = mysql_query($query)
or die (mysql_query());
$total = 0;
while ($row = mysql_fetch_array($results)) {
extract($row);
$prod = "SELECT * FROM products WHERE
products_prodnum = '$carttemp_prodnum'";
$prod2 = mysql_query($prod);
$prod3 = mysql_fetch_array($prod2);
extract($prod3);
echo "<tr><td>";
echo $carttemp_quan;
echo "</td>";
echo "<td>";
echo "<a href=\"getprod.php?prodid=" .
$products_prodnum . "\">";
echo '<IMG SRC="',$products_image,
'" WIDTH="100" HEIGHT="80" BORDER="0" ALT=""/>';
echo "</a></td> ";
echo "<td>";
echo "<a href=\"getprod.php?prodid=" .
$products_prodnum . "\">";
echo $products_name;
echo "</td></a>";
echo "<td align=\"right\">";
echo $products_price;
echo "</td>";
echo "<td align=\"center\">";
echo $products_unit;
echo "</td>";
echo "<td align=\"right\">";
//get extended price
$extprice = number_format($products_price * $carttemp_quan, 2);
echo $extprice;
echo "</td>";
echo "<td>";
echo "<a href=\"cart.php\">Make Changes to Cart</a>";
echo "</td>";
//add extended price to total
$total += $extprice;

$total2 = number_format($extprice,2);
echo "<td>";
echo $total2;
echo "</td>";
echo "</tr>";
}
?>
<tr>
<td colspan="5" align="right">Your total before shipping is:</td>
<td align="right"> <?php echo number_format($total, 2); ?></td>
<td></td>
<td></td>
</tr>
</table>