Jump to content

[resolved]updating price not working


cinek
 Share

Recommended Posts

I'm trying to update the total price every time a user adds a new item to the basket or adds an existing item which increases the quantity. This is what I have right now:

for($i = 1; $i <= $size2; $i++){			//echo table			$get_product_name = 'SELECT * FROM products WHERE product_id = "'. $_SESSION['cart'][$i]['productID'] . '"';						$get_name_query = mysql_query($get_product_name);									while ($row = mysql_fetch_array($get_name_query)){				if($check_page != "basket"){					echo "<tr>";					echo "<td class='left'>" . $_SESSION['cart'][$i]['qty'] . "x <a href='index.php?category=" .$row['type_id'] . "&product_id= " . $row['product_id'] . "'>" . $row['product_name_short'] . "</a></td>";					echo "<td class='right'><h4> £" . $row['product_price'] . "</h4></td>";					echo "</tr>";				} else {					echo '<tr>';						echo '<td>';					echo '<img src="pictures/' . $row['product_id'] . '/thumb1.jpg" alt="product"/>';					echo '<a href="index.php?category'. $row['type_id'] . '&product_id=' . $row["product_id"] . '"><h4>' . $row["product_name_short"] . '</h4></a>';					echo '<form action="' . $current_url . '" method="post">';					echo '<label>£'. $row["product_price"] . '</label>';					echo '<input type="text" value="1" maxlength="2" name="quantity"/>';					echo '<input type="hidden" value="' . $row["product_id"] . '" name="product"/>';					echo '<input type="hidden" value="' . $row["product_price"] . '" name="product_price"/>';					echo '<input type="submit" value="Update"/>';					echo '</form>';					echo '</td>';					echo '</tr>'; 				}								if(!isset($total)){					$total = $row['product_price'];				} else {									$total += ($row['product_price'] * $_SESSION['cart'][$i]['qty']);													}			} 

it only works for the last item that was added to the basket edit: nvm sorted

Edited by cinek
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...