Jump to content
Larry Ullman's Book Forums

Chapter 19 - Issue With Script 19.10


Recommended Posts

Hi there! I encountered a problem within the view_cart.php script that has to do with the only input field  - Quantity. When there's already something in the cart, the quantity can't be changed manually and after I press the Update My Cart button nothing changes and the already preset qty is again displayed.

 

Here is the part of the script that in my opinion is problematic:

61 // Print the returned records
62		echo "\t<tr>
63				<td align=\"left\">{$row['artist']}</td>
64				<td align=\"left\">{$row['print_name']}</td>
65				<td align=\"right\">\${$_SESSION['cart'][$row['print_id']]['price']}</td>
66				<td align=\"center\"><input type=\"text\" size=\"3\" name=\"qty[{$row['print_id']}]\" value=\"{$_SESSION['cart'][$row['print_id']]['quantity']}\" /></td>
67				<td align\"right\">$" . number_format($subtotal, 2) . "</td>
68			</tr>\n"; 

My guess is that because the value argument is preset with the quantity coming from the session (line 66 of the script), nothing else can be entered into the qty field.

 

Has anybody encountered the same issue? What would the work around be?

 

Thank you for taking the time!

 

Link to comment
Share on other sites

Hmmm...the code was working as I tested it when I wrote the book. I imagine the problem is somewhere else. The value there comes from $_SESSION['cart'][$row['print_id']]['quantity'], so I'd check if that value isn't being changed earlier in the script as it should be.

Link to comment
Share on other sites

 Share

×
×
  • Create New...