1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Rep Power

    Hide sections if post value is empty

    Hi all
    Hoping someone can offer some insights into how i might go about the following. I have a form passing information to a checkout page, however I don't want to display all products/quantities if the user didn't select that particular quantity.
    Below is my code for the second page (if needed i can upload code for first page, but didn't think was necessary):

    PHP Code:
    <!DOCTYPE html>
    <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
    <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
    <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
    <!--[if (gte IE 9)|!(IE)]><!--><html dir="ltr" lang="en"> <!--<![endif]-->
        <!-- Basic Page Needs
      ================================================== -->
        <meta charset="utf-8">
    <title>Adlantic.ie: Riverdance Store</title>
            <meta name="description" content="Adlantic.ie: Online Store" />
                    <link href="img/data/cart.png" rel="icon" />
        <!-- Mobile Specific Metas
      ================================================== -->
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <?php include("cssjs.php"?>
        <!-- Custom Css
        ================================================== -->
        <link rel="stylesheet" id="active-bg" href="resources/css/bg/soft_wallpaper.css">

    <style type="text/css">
    div.featured ul li { min-height: 320px!important;}
    div.latest ul li { min-height: 320px!important;}
    div.special ul li { min-height: 320px!important;}
    #products_grid ul.product_show li { min-height: 320px!important;}
    #products_grid_4_cols ul.product_show li { min-height: 320px!important;}
    div.related ul li { min-height: 320px!important;}
    ul.customListStyle li {
            margin: 0;
        padding:6px 0 6px 20px;
        background: url('resources/img/icons/arrow_right.png') no-repeat left center;
    <script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-41482001-1']);
      _gaq.push(['_setDomainName', 'adlantic.ie']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

    <script type="text/javascript">
    $(function() {
    $men_med $_POST['men_med']; 
    $men_large $_POST['men_large']; 
    $men_xlarge $_POST['men_xlarge']; 
    $women_small $_POST['women_small']; 
    $women_med $_POST['women_med']; 
    $kids_xsmall $_POST['kids_xsmall']; 
    $kids_small $_POST['kids_small']; 
    $kids_med $_POST['kids_med']; 
    $kids_large $_POST['kids_large']; 
    $kids_xlarge $_POST['kids_xlarge']; 
    $price "10";
    $region $_POST['region'];

    <?php include("header.php"?>

    <div class="container">
    <div class="sixteen columns">
       <h2> Your Order : </h2>
        <table width="800px" cellspacing="0">
            <tr valign="top" bgcolor="#00CCFF"><td><strong>Product</strong></td><td><strong>Price Each</strong></td><td><strong>Quantity</strong></td><td><strong>Item Total</strong></td></tr>
            <tr valign="top"><td>Mens Red Tee Shirt</td><td> @ 10 incl VAT</td><td><?php echo $men_small?> x Small<br />
                                                                        <?php echo $men_med?> x Medium<br />
                                                                        <?php echo $men_large?> x Large<br />
                                                                        <?php echo $men_xlarge?> x Extra Large<br /></td>
                      <td>    <?php $men_small_total $men_small $price ?><?php echo $men_small_total?> <br />
                            <?php $men_med_total $men_med $price ?><?php echo $men_med_total?> <br />
                            <?php $men_large_total $men_large $price ?><?php echo $men_large_total?> <br />
                            <?php $men_xlarge_total $men_xlarge $price ?><?php echo $men_xlarge_total?> <br /></td>
            <tr valign="top"><td></td><td></td><td><strong>Men's Total</strong></td><td><?php $mens_total = ($men_small_total $men_med_total $men_large_total $men_xlarge_total); ?>
            <strong><?php echo $mens_total?></strong><br /><br /></td></tr>
            <tr valign="top"><td>Womens Black Tee Shirt</td><td> @ 10 incl VAT</td><td><?php echo $women_small?> x Small<br />
                                                                        <?php echo $women_med?> x Medium<br />  </td>
                            <td><?php $women_small_total $women_small $price ?><?php echo $women_small_total?> <br />
                                <?php $women_med_total $women_med $price ?><?php echo $women_med_total?> <br /> </td>
            <tr valign="top"><td></td><td></td><td><strong>Women's Total</strong></td><td><?php $womens_total = ($women_small_total $women_med_total); ?>
                    <strong><?php echo $womens_total?></strong><br /><br /></td></tr>

            <tr valign="top"><td>Kids Tee Shirt</td><td> @ 10 incl VAT</td><td><?php echo $kids_xsmall?> x Extra Small <br />
                                                                        <?php echo $kids_small?> x Small <br />
                                                                        <?php echo $kids_med?> x Medium<br />
                                                                        <?php echo $kids_large?> x Large<br />
                                                                        <?php echo $kids_xlarge?> x Extra Large<br /></td>
                            <td><?php $kids_xsmall_total $kids_xsmall $price ?><?php echo $kids_xsmall_total?> <br />
                                <?php $kids_small_total $kids_small $price ?><?php echo $kids_small_total?> <br />
                                <?php $kids_med_total $kids_med $price ?><?php echo $kids_med_total?> <br />
                                <?php $kids_large_total $kids_large $price ?><?php echo $kids_large_total?> <br />
                                <?php $kids_xlarge_total $kids_xlarge $price ?><?php echo $kids_xlarge_total?> <br /></td>
                <tr valign="top"><td></td><td></td><td><strong>Kids Total</strong></td><td><?php $kids_total = ($kids_xsmall_total $kids_small_total $kids_med_total $kids_large_total $kids_xlarge_total); ?>
                    <strong><?php echo $kids_total?></strong><br /><br /></td></tr>

        <tr valign="top"><td></td><td></td><td>Subtotal</td><td><?php $subtotal $mens_total $womens_total $kids_total?><?php echo $subtotal?></td></tr>
        <tr valign="top">
          <td></td><td></td><td>Post & Packaging</td><td><?php include("pricing.php"); ?><?php echo $pp?></td></tr>
        <tr valign="top"><td></td><td></td><td>Total</td><td><?php $total = ($subtotal $pp); ?><?php echo $total?></td></tr>

    <?php include("footer.php"?>

    <?php include("sidebar.php"?>

    <!-- End Document
    ================================================== -->
    thanks to all for taking time to read/help

  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Pennsylvania, USA
    Rep Power
    This code is a bit of a mess. I don't even see any loops anywhere, you appear to do every line manually.

    I guess you should just wrap each line in an IF statement saying "if there's a quantity." No else, just the IF. If there's no quantity, it won't print.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo