callisto11 Posted March 20, 2008 Share Posted March 20, 2008 THIS IS MY CODE FOR MY CHECKOUT SCRIPT, IM TRYIN TO ADD ALL THE QUANTITY TOGETHER AND ALL THE PRICE TOGETHER AND GET IT TO DISPLAY IN THE TOTAL QUANTITY FIELD AND TOTAL PRICE FIELD, BUT I DONT THINK IM USING THE COUNT ELEMENT RIGHT. I'VE HAD A GO BUT I DONT KNOW WHATS HAPPEN COZ IT NOT DOING ANYTHING. I DON'T THINK I'VE PUT IN THE RIGHT WAY. PLS HELP, IM VERY NEW TO PHP. I'VE HIGHLIGHT MY PROBLEM AREA IN RED. ??? <?php session_start(); ?> <?=$_SESSION['customer_id']?></p></a> <?php if (isset ($_SESSION['cart'])){ ?> <body> <center> <h1><img src="logo.jpg" align=center width="400" height="110"></h1> </center> <font face="scans-serif" color="Purple" size="5" align="right" >Order</font> <p><?php $usr = $_SESSION['email']; echo $usr;?>logged In</p> <p>Please Check your order</p> <table width="30%" border="1" bgcolor=""> <tr> <th width="5%"> STYLE NUMBER</th> <th width="6%"> DETAILS</th> <th width="6%"> QUANTITY</th> <th width="7%"> SIZE </th> <th width="7%"> PRICE </th> <?php foreach ($_SESSION['cart'] as $key => $general_cartoon) { ?> <tr> <td><?php echo $_SESSION['cart'][$key] ['cartoon_id']; ?></td> <td><?php echo $_SESSION['cart'][$key] ['title']; ?></td> <td><?php echo $_SESSION['cart'][$key] ['quantity'];?></td> <td><?php echo $_SESSION['cart'][$key] ['size'];?></td> <td><?php echo $_SESSION['cart'][$key] ['price'];?></td> <?php $quantity =$_SESSION['cart'][$key]['quantity'];?> <td> <tr> <td><?php $total_quantity = count($quantity); ?></td> <td><?php $total_order_of_order = count($price); ?></td> </tr> <tr> <?php } ?> <tr></tr> <td></td> <td>Total Quantity</td> <td> <?php echo $total_quantity ?> </td> <td></td> <tr></tr> <td></td> <td>Total Price</td> <td><?php echo $total_cost_of_order ?></td> </tr> </table> <p> To proceed to checkout press</p> <td><a href="rmcheckoutform.php">Continue</a> </td> <?php } else { ?> NOTHING IN YOUR CART <?php } ?> <p> For any amendments please return to your shopping cart</p> <a href="shoppingcart.php">Shopping Cart</a> </body> </html> Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/ Share on other sites More sharing options...
RottNKorpse Posted March 20, 2008 Share Posted March 20, 2008 <td> <?php echo $total_quantity ?> </td> <td></td> <tr></tr> <td></td> <td>Total Price</td> <td><?php echo $total_cost_of_order ?></td> You need to close your echos... echo $total_quantity; without the ; the echo never ends thus breaking the code. Ps. PLEASE take off your caps lock...that is annoying. There are a lot of people here to help and capping everything to get attention to your question is just going to irritate people. Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497183 Share on other sites More sharing options...
cooldude832 Posted March 20, 2008 Share Posted March 20, 2008 fyi if u turn on error reporting to fix problems it makes stuff a lot easier Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497185 Share on other sites More sharing options...
callisto11 Posted March 20, 2008 Author Share Posted March 20, 2008 i've closed the echo's and its still not counting the fields! Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497188 Share on other sites More sharing options...
RottNKorpse Posted March 20, 2008 Share Posted March 20, 2008 <?=$_SESSION['customer_id']?></p>[/url] Please fix the code you provided in your post...because that doesn't make any sense at all. Also yes...as cooldude832 said, turn on error reporting. Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497190 Share on other sites More sharing options...
callisto11 Posted March 20, 2008 Author Share Posted March 20, 2008 sorry about the cap, im quite new to the forum! Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497192 Share on other sites More sharing options...
pauleth Posted March 20, 2008 Share Posted March 20, 2008 Maybe I'm a retard, but I don't see where you actually defined the $price array. Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497195 Share on other sites More sharing options...
thebadbad Posted March 20, 2008 Share Posted March 20, 2008 You need to close your echos... echo $total_quantity; without the ; the echo never ends thus breaking the code. Actually you don't need the semi-colon when the statement is immediately followed by a PHP closing tag. But I always do it, and it sure is good practice. Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497196 Share on other sites More sharing options...
callisto11 Posted March 20, 2008 Author Share Posted March 20, 2008 THIS IS MY CODE FOR MY CHECKOUT SCRIPT, IM TRYIN TO ADD ALL THE QUANTITY TOGETHER AND ALL THE PRICE TOGETHER AND GET IT TO DISPLAY IN THE TOTAL QUANTITY FIELD AND TOTAL PRICE FIELD, BUT I DONT THINK IM USING THE COUNT ELEMENT RIGHT. I'VE HAD A GO BUT I DONT KNOW WHATS HAPPEN COZ IT NOT DOING ANYTHING. I DON'T THINK I'VE PUT IN THE RIGHT WAY. PLS HELP, IM VERY NEW TO PHP. I'VE HIGHLIGHT MY PROBLEM AREA IN RED. Im very sorry everyone, all this, is very new to me! Pls tak with e it easy with me. I've added the ; to close the echo, i've removed the session on cartoon_id, but i still not gettin what i want to work! <?php session_start(); ?> <?php if (isset ($_SESSION['cart'])){ ?> <body> <center> <h1><img src="logo.jpg" align=center width="400" height="110"></h1> </center> <font face="scans-serif" color="Purple" size="5" align="right" >Order</font> <p><?php $usr = $_SESSION['email']; echo $usr;?>logged In</p> <p>Please Check your order</p> <table width="30%" border="1" bgcolor=""> <tr> <th width="5%"> STYLE NUMBER</th> <th width="6%"> DETAILS</th> <th width="6%"> QUANTITY</th> <th width="7%"> SIZE </th> <th width="7%"> PRICE </th> <?php foreach ($_SESSION['cart'] as $key => $general_cartoon) { ?> <tr> <td><?php echo $_SESSION['cart'][$key] ['cartoon_id']; ?></td> <td><?php echo $_SESSION['cart'][$key] ['title']; ?></td> <td><?php echo $_SESSION['cart'][$key] ['quantity'];?></td> <td><?php echo $_SESSION['cart'][$key] ['size'];?></td> <td><?php echo $_SESSION['cart'][$key] ['price'];?></td> <?php $quantity =$_SESSION['cart'][$key]['quantity'];?> <td> <tr> <td><?php $total_quantity = count($quantity); ?></td> <td><?php $total_order_of_order = count($price); ?></td> </tr> <tr> <?php } ?> <tr></tr> <td></td> <td>Total Quantity</td> <td> <?php echo $total_quantity; ?> </td> <td></td> <tr></tr> <td></td> <td>Total Price</td> <td><?php echo $total_cost_of_order; ?></td> </tr> </table> <p> To proceed to checkout press</p> <td><a href="rmcheckoutform.php">Continue[/url] </td> <?php } else { ?> NOTHING IN YOUR CART <?php } ?> <p> For any amendments please return to your shopping cart</p> <a href="shoppingcart.php">Shopping Cart[/url] </body> </html> Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497204 Share on other sites More sharing options...
callisto11 Posted March 20, 2008 Author Share Posted March 20, 2008 What my code is surpose to do, is print the information inside the shopping cart and then calculate the total quantity and total price. I know im missin something in the code but i don't know it is. Thats the problem im having. Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497207 Share on other sites More sharing options...
RottNKorpse Posted March 20, 2008 Share Posted March 20, 2008 we are going about it the wrong way...where did you get this script and if it is a shopping cart system what is it called...(examples: OSCommerce, CubeCart, ZenCart, etc.) Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497211 Share on other sites More sharing options...
Barand Posted March 20, 2008 Share Posted March 20, 2008 THIS IS MY CODE FOR MY CHECKOUT SCRIPT, IM TRYIN TO ADD ALL THE QUANTITY TOGETHER AND ALL THE PRICE TOGETHER AND GET IT TO DISPLAY IN THE TOTAL QUANTITY FIELD AND TOTAL PRICE FIELD, BUT I DONT THINK IM USING THE COUNT ELEMENT RIGHT. I'VE HAD A GO BUT I DONT KNOW WHATS HAPPEN COZ IT NOT DOING ANYTHING. I DON'T THINK I'VE PUT IN THE RIGHT WAY. PLS HELP, IM VERY NEW TO PHP. I'VE HIGHLIGHT MY PROBLEM AREA IN RED. If you still insist on shouting, I certainly am not going to read any further. Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497214 Share on other sites More sharing options...
callisto11 Posted March 20, 2008 Author Share Posted March 20, 2008 This is my code for my checkout script, Im tryin to add all the quantity field together and all the price field together and get it to display in the total quantity fields and total price field, but I dont think im using the right element element right. I've had a go but I dont know whats happening coz it not doing anything. I dont think i've done it the right way, I've Hightlight my problem area in red. Im very sorry everyone, all this, is very new to me! Pls tak with e it easy with me. I've added the ; to close the echo, i've removed the session on cartoon_id, but i still not gettin what i want to work! It's an old code from my last checkout script i made, im reusing it. <?php session_start(); ?> <?php if (isset ($_SESSION['cart'])){ ?> <body> <center> <h1><img src="logo.jpg" align=center width="400" height="110"></h1> </center> <font face="scans-serif" color="Purple" size="5" align="right" >Order</font> <p><?php $usr = $_SESSION['email']; echo $usr;?>logged In</p> <p>Please Check your order</p> <table width="30%" border="1" bgcolor=""> <tr> <th width="5%"> STYLE NUMBER</th> <th width="6%"> DETAILS</th> <th width="6%"> QUANTITY</th> <th width="7%"> SIZE </th> <th width="7%"> PRICE </th> <?php foreach ($_SESSION['cart'] as $key => $general_cartoon) { ?> <tr> <td><?php echo $_SESSION['cart'][$key] ['cartoon_id']; ?></td> <td><?php echo $_SESSION['cart'][$key] ['title']; ?></td> <td><?php echo $_SESSION['cart'][$key] ['quantity'];?></td> <td><?php echo $_SESSION['cart'][$key] ['size'];?></td> <td><?php echo $_SESSION['cart'][$key] ['price'];?></td> <?php $quantity =$_SESSION['cart'][$key]['quantity'];?> <td> <tr> <td><?php $total_quantity = count($quantity); ?></td> <td><?php $total_order_of_order = count($price); ?></td> </tr> <tr> <?php } ?> <tr></tr> <td></td> <td>Total Quantity</td> <td> <?php echo $total_quantity; ?> </td> <td></td> <tr></tr> <td></td> <td>Total Price</td> <td><?php echo $total_cost_of_order; ?></td> </tr> </table> <p> To proceed to checkout press</p> <td><a href="rmcheckoutform.php">Continue[/url] </td> <?php } else { ?> NOTHING IN YOUR CART <?php } ?> <p> For any amendments please return to your shopping cart</p> <a href="shoppingcart.php">Shopping Cart[/url] </body> </html> Link to comment https://forums.phpfreaks.com/topic/97163-need-help-with-count-element-in-php-for-my-checkout-script/#findComment-497229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.