www.webdeveloper.com
Results 1 to 9 of 9

Thread: echo $total works in Firefox but not IE

  1. #1
    Join Date
    Jul 2009
    Posts
    16

    echo $total works in Firefox but not IE

    I reckon this is a simple problem but in my basket where I display my total there is a code:

    Code:
    <?php echo $total; ?>
    Which displays the total of all the prices:

    Code:
    <?php if ($rug['special_offer']) { echo $rug['discount_price']; $total += $rug['discount_price']*$rug['qty']; } else { echo $rug['price']; $total += $rug['price']; } ?>
    Of items in the basket.

    This seems to work fine in the latest Firefox but in IE8 the total remains at 0.00.

    Any ideas?

  2. #2
    Join Date
    Nov 2008
    Posts
    2,477
    Browser wont have anything to do with it directly as PHP does its thing server side. Maybe IE is serving a cached version of the page?

  3. #3
    Join Date
    Jul 2009
    Posts
    16
    The cache isn't the problem, there's the same problem on different computers.

    I'd imagine it'll be something very simple but just now it's really confusing me. Possibly a CSS issue?

  4. #4
    Join Date
    Nov 2008
    Posts
    2,477
    Yes it's much more likely to be a HTML/CSS issue. Have a look in the source code and see if the data is there.

  5. #5
    Join Date
    Jul 2009
    Posts
    16
    I was thinking that it couldn't be anything to do with php but at the same time in Internet Explorer it's not like it's not showing anything where the code is, it's giving 0.00 as if its counting in firefox but not in explorer.

    confused.com!
    Last edited by little-persia; 10-10-2009 at 08:53 AM.

  6. #6
    Join Date
    Jul 2009
    Posts
    16
    Whole code here:

    HTML Code:
     <h3>What's in my Shopping Basket?</h3>
                    
    
                  
                        <?php if (!count($rugs)): ?>
                        <p class="noproduct">No products in your Basket.</p>
                        <?php endif; ?>
                        
     
                       
    
    
    <!-- //product -->
                        <?php $total = 0; ?>
                        <form action="" method="post" id="basket_form">
                       
                       
                        <?php foreach ($rugs as $rug): ?>
                        
                        
                      <div id="products" style="border:solid #736B58 1px; padding:8px; height:200px; color:#736B58">  
                      
                      
                      
                      <div class="left" style="float:left">
                      
                       <div class="checkbox">Remove Rug<input type="checkbox" name="remove[<?php echo $rug['id']; ?>]" style="border:none" value="1" /></div>
    					<div class="product_photo" style="margin-top:12px"><a href="http://www.love-rugs.com/?id=<?php echo $rug['id']; ?>&amp;action=search&amp;=Search"><img src="http://www.little-persia.com/img/<?php if ($rug['main_photo_id']) echo $rug['id']."_".$rug['main_photo_id']; else echo "nophoto"; ?>_small.jpg"  alt="" /></a></div>
                          
                        </div>
                          
                          <div class="right" style="float:left; margin-left:14px">
    						  <p style="margin-top:3px"><strong>Reference: R<?php echo $rug['id']; ?></strong></p>
                              <p>Length: <?php echo round($rug['length']/0.3, 2); ?> ft (<?php echo $rug['length'];?> m)</p>
                              <p>Width: <?php echo round($rug['width']/0.3, 2); ?> ft (<?php echo $rug['width'];?> m)</p>
                              <p>Type: <?php echo $rug['origin']; ?></p>
                              <p>Design: <?php echo $rug['name']; ?></p>
                           	
    
                          <div class="how_much" style="margin-top:25px">
                          <p>Price: &pound;<?php if ($rug['special_offer']) { echo $rug['discount_price']; $total += $rug['discount_price']*$rug['qty']; } else { echo $rug['price']; $total += $rug['price']; } ?></p>
                          </div>
                            
                          <div class="quantity" style="margin-top:16px">
                          <p>Quantity: <input type="text" name="qty[<?php echo $rug['id']; ?>]" value="<?php echo $rug['qty']; ?>"></p>
                          </div>
    
                        </div>
                           
                          </div>
                            
                           <div class="clear"></div>
                           <p>&nbsp;</p>
                           
                      <?php endforeach; ?> 
                        
                     
                      
                   
    
                      <!-- // finish product -->
                      <p><strong>Total: &pound;<?php echo $total; ?></strong></p>
                      <p>
                   
                        <input type="button" name="input" value="Go To Bookmarked Rugs" onclick="document.location='?action=bookmarked'"/>
                        </span>
                        <input type="submit" name="" value="Remove From Basket" onclick="document.getElementById('basket_form').action='?action=delete_basket_item'" />
                        <input type="button" name="" value="Continue Shopping" onclick="document.location='?action=last_search'" />
                        <input type="button" name="" value="Proceed To Checkout" onclick="document.location='?action=checkout'" />
                        </form></p>

  7. #7
    Join Date
    Oct 2009
    Posts
    9
    Hiiii....check the version of PHP you are using .......and also the browsers it supports..

  8. #8
    Join Date
    Jan 2009
    Posts
    3,346
    PHP doesn't support browsers it is a server-side language. In the code above you are using a syntax I'm not familiar with:
    PHP Code:
    <?php if(condition):?>
    some stuff
    <?php endif; ?>
    and
    PHP Code:
    <?php foreach(conditions):?>
    some stuff
    <?php endforeach;?>
    The syntax I'm familiar with is more like:
    PHP Code:
    <?php if(condition){?>
    some stuff
    <?php ?>
    and
    PHP Code:
    <?php foreach(conditions){ ?>
    some stuff
    <?php ?>
    Not sure if that will affect you problem.

  9. #9
    Join Date
    Sep 2008
    Location
    Mexico
    Posts
    786
    HTML Code:
    <input type="submit" name="" .... />
    is your problem... IE requires that a "name" to be specified for an input tag without exception. It's a good habit to also add the "id" to ensure cross-browser compatibility.
    HTML Code:
    <input type="submit" name="remove" id="remove" ... />
    <input type="submit" name="continue" id="continue" ... />
    <input type="submit" name="checkout" id="checkout" ... />
    Last edited by opifex; 10-19-2009 at 08:22 AM.
    ...but stupidity is terminal.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles