|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
showcart.php
Hi all,
I'm trying to get the shoppingcart from the tutorial on this site to work. I've modified it a bit, and now I'm stuck. i cant get the showcart.php to work it just gives a blank page. below is the code showcart.php <? function ShowCart() { $result = mysql_query("select * from cart inner join products on cart.item_id = products.item_id where cart.cookie_id = '" . GetCartId() . "' order by products.item_name asc") or mysql_error($result); // once we've retrieved the list, each item is displayed as part of a table, as a table row echo "<table border='1' cellspacing='0' cellpadding='2' class='cart'>"; $color1 = "gray"; $color2 = "lightgray"; $row_count = 0; while($row = mysql_fetch_array($result)) { // increment the total cost of all items $totalCost += ($row["qty"] * $row["item_price"]); // alternating table colors $row_color = ($row_count % 2) ? $color1: $color2; ?> <tr><td bgcolor="<?php echo $row_color;?>"> <font face='verdana' size='1' color='black'> <select name='<?php echo $row['item_id'];?>' onChange='UpdateQty(this)' <?php for ($i = 1; $i <= 20; $i++) { echo "<option "; if ($row["qty"] == $i) { echo " SELECTED "; } echo ">" . $i . "</option>"; } ?> </select></font></td> <td width="60%" height="25" bgcolor="<?php echo $row_color;?>"> <font style="color:#FFFFFF;font-size:12pt;font-weight:bold;" face="verdana,arial,helvetica,sans-serif" size='1' color='black'> <?php echo $row["item_name"];?> </font></td> <td width="20%" height="25" bgcolor="<?php echo $row_color;?>"> <font style="font-size:12pt;font-weight:bold;" face='verdana' size='1' color='white'>$ <?php echo number_format($row['item_price'], 2, '.', ',');?></font> </td> <td width="10%" height="25" bgcolor="<?php echo $row_color;?>"> <font face='verdana' size='1' color='black'> <a href=cart.php?action=remove_item&id=<?php echo $row['item_id'];?>>Remove</a> </font></td> </tr> <?php // increase row count by 1 $row_count++; } ?> <tr><td width='100%' colspan='4'> <hr size='1' color='red' NOSHADE> </td></tr> <tr><td width='70%' colspan='2'> <font face='verdana' size='1' color='black'> <a href='products.php'><< Keep Shopping</a> </font></td> <td width='30%' colspan='2'> <font face='verdana' size='2' color='black'> <b>Total: <?php echo number_format($totalCost, 2, ".", ",");?> </b> </font></td></tr> </table> <?php } thanks |
|
#2
|
||||
|
||||
|
for future reference, put [ php][/php ] blocks around the PHP code and the forum will color-ize your code...
i don't know if its the way you posted it, but you're missing a ?> at the end of your code... Quote:
Additionally, I can't really tell from the indenting, but is the entire script declared as a function? In which case, it may help to call the function at the end... |
|
#3
|
|||
|
|||
|
im new to php some not used to the indenting
showcart.php only has one function thanks |
|
#4
|
||||
|
||||
|
is it being called?
perhaps you're missing ShowCart() somewhere? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > showcart.php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|