Jump to content

need help with count element in php (for my checkout script


callisto11

Recommended Posts

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
Share on other sites

   <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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.