Niksou Posted August 2, 2020 Share Posted August 2, 2020 hello , Im working on a fictional web-site as a final project for my course. Im having a little trouble with placing php includes in my page and also printing the total sum of my order. also im not sure how or where to place the order now button in order.php'\. here is my git , most of the necessery code if found in order.phphttps://github.com/niksou/ProjectWeb Quote Link to comment Share on other sites More sharing options...
gw1500se Posted August 2, 2020 Share Posted August 2, 2020 Don't make people go to a 3rd party web site. Post your code here using the code icon (<>) and specify PHP. Quote Link to comment Share on other sites More sharing options...
Niksou Posted August 3, 2020 Author Share Posted August 3, 2020 < <h3>Order Details</h3> <div class="table-responsive"> <table class="table table-bordered"> <tr> <th width="40%">Item Name</th> <th width="10%">Quantity</th> <th width="20%">Price</th> <th width="15%">Total</th> </tr> <?php $total=0; $itemCount=0; $first=false; for($i=0;$i<6;$i++) { $title = ($_POST['hidden_name'.$i]); $price = ($_POST['hidden_price' . $i]); $quantity = ($_POST['quantity' . $i]); ?> <?php if($quantity>0){ $shortStr= substr($price,1,-1); $flatVal=(float)$shortStr; $flatVal=$flatVal*$quantity; $totalItem=$flatVal*$quantity; $total+=$flatVal; ?> <tr> <td><?php echo $title; ?></td> <td><?php echo $quantity; ?></td> <td> <?php echo $price; ?></td> <td> <?php echo $totalItem;?></td> <td> </tr> <?php } if($i==5){ echo"Order total : $total"; } } ?> <br> <br> <br> > Quote Link to comment Share on other sites More sharing options...
gw1500se Posted August 3, 2020 Share Posted August 3, 2020 (edited) 1. please use the code icon (<>) and specify PHP. It makes your code much easier to read. 2. learn to indent your code. 3. what is up with ?> and <?php and no intervening HTML? It makes it very difficult to see where your code blocks end. Your code should look more like this: for($i=0;$i<6;$i++) { $title = ($_POST['hidden_name'.$i]); $price = ($_POST['hidden_price' . $i]); $quantity = ($_POST['quantity' . $i]); if($quantity>0){ $shortStr= substr($price,1,-1); $flatVal=(float)$shortStr; $flatVal=$flatVal*$quantity; $totalItem=$flatVal*$quantity; $total+=$flatVal; } } I didn't include everything in the loop and if blocks as it is too difficult to follow but you should get the idea. Edited August 3, 2020 by gw1500se Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.