34 users online (0 members and 34 guests)  


Page 1 of 2 1 2 Last
  Results 1 to 15 of 26

Related

  1. Side by side html tables    Forum: HTML Forum
    Replies: 7
  2. Replies: 2
  3. PHP / MYSQL Side Menu    Forum: PHP Forum
    Replies: 6
  4. Replies: 4
  5. Replies: 4
  1. #1
    bufhal's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Apr 2006
    Posts
    32

    side menu item only shows when DB has item in field

    Hello;
    I am stuck and hope someone can help me.
    I have a menu attached to a MySQL DB that has various items stored and are called with PHP when a user clicks on the link.
    (I included the menu code below to help show where I'm at)
    I want to add a menu item that is only visible if there is something stored in the DB.
    I bolded the area below as to the part of the menu I want the field.
    I have scoured the Web and Googled but could not find a way to do this. Can someone please show me how to incorporate this in that general area with PHP?
    I appreciate any help. Thank you in advance.

    <table cellspacing="0" cellpadding="0" id="menu2" class="ddmx">
    <tr>
    <td>
    <td bordercolor="#000000">
    <a class="item3 arrow" href="javascript:void(0)">Product Information<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>

    <div style="border: 2px; #FFFFFF" class="section">

    <a class="item2" href="<?php echo $tech_url; ?>"> Tech Sheet - <?php echo $techsheet; ?> </a>
    <a class="item2" href="<?php echo $broch_url; ?>"> Product Brochure - <?php echo $brochure; ?> </a>
    <a class="item2" href="/howtobuy.html">How to Buy</a>
    </div>

    <a class="item3 arrow" href="javascript:void(0)">Drivers & Downloads<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="<?php echo $soft_url; ?>">Software - <?php echo $soft; ?></a>

    <a class="item2" href="/products.html">Product Information</a>
    </div>
    <a class="item3 arrow" href="javascript:void(0)">Manuals & Specifications<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="<?php echo $manual_url; ?>"> Manual - <?php echo $manual; ?> </a>
    <a class="item2" href="/trouble.html">FAQs</a>
    </div>
    <a class="item3 arrow" href="">Certifications<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>

    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/certs.html">Partner Certifications</a>
    </div>
    <a class="item3 arrow" href="javascript:void(0)">Support & Service<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/techsupt.html">Contact Tech Support</a>
    <a class="item2" href="/trouble.html">Troubleshooting Tips & FAQs</a>
    <a class="item2" href="/warrantyinfo.html">Warranty Information</a>
    <a class="item2" href="/license.php">Authorize Products</a>
    <a class="item2" href="/registration.php">Register Products</a>
    <a class="item2" href="/services/index.html">Service Programs</a>
    </div>
    <a class="item3 arrow" href="javascript:void(0)">Request Information<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/oem.html">Request Sales Support</a>
    <a class="item2" href="/techsupt.html">Request Technical Support</a>
    <a class="item2" href="/techsupt.html">Request Technical Support</a>
    <a class="item2" href="/techsupt.html">Request Technical Support</a>
    </div>
    <a class="item3 arrow" href="javascript:void(0)">Solutions<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/oemsolutions.html">OEM</a>
    <a class="item2" href="/digitalcc.html">Digital Content Creation</a>
    <a class="item2" href="/business.html">Backup</a>
    </div>

    </td>
    </tr>
    </table>

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: side menu item only shows when DB has item in field

    You just need something sort of like this where you had your bolded text:

    Code:
    <?php
    if ($db_field == 'whatever') {
    ?>
    <a class="item2" href="/techsupt.html">Request Technical Support</a>
    <?php
    }
    ?>
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  3. #3
    bufhal's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Apr 2006
    Posts
    32

    Re: side menu item only shows when DB has item in field

    Thanks for the comment. I added this:
    <?php
    if ($db_field == 'url15') {
    ?>
    <a class="item2" href="<?php echo $url15; ?>"> Special <?php echo $url15; ?> </a>
    <?php
    }
    ?>
    I entered info inot the url15 field of the DB. Nothing.
    Are my PHP tags off?

  4. #4
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: side menu item only shows when DB has item in field

    Quote Originally Posted by bufhal
    Hello;
    I am stuck and hope someone can help me.
    I have a menu attached to a MySQL DB that has various items stored and are called with PHP when a user clicks on the link.
    (I included the menu code below to help show where I'm at)
    I want to add a menu item that is only visible if there is something stored in the DB.
    I bolded the area below as to the part of the menu I want the field.
    I have scoured the Web and Googled but could not find a way to do this. Can someone please show me how to incorporate this in that general area with PHP?
    I appreciate any help. Thank you in advance.
    Forgive my ignorance, but I am confused as to what exactly you want to do.
    It looks like you want to read the links from the database, and display them if there is a valid entry stored, but the bit you emboldened only highlighted the fact that you appear to have 3 Tech support links!

    I'm sure this is workable, it's just a case of getting a handle on what you're after!

  5. #5
    bufhal's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Apr 2006
    Posts
    32

    Re: side menu item only shows when DB has item in field

    Thanks for the reply Deadmeat. I will try to explain it clearer, I guess I was rambling a bit.
    I want a field at the bottom of the menu to only appear if there is an item in the database (url15). If nothing exists in the db, nothing will show.
    I know I did this wrong but I want the word "Special" to appear and be the link to the item in the db id there is an item, only.
    Below is the new menu code--perhaps this will give you a broader view of what I am trying to do.
    Thanks again..I hope this clears it up a bit.

    <table cellspacing="0" cellpadding="0" id="menu2" class="ddmx">
    <tr>
    <td>
    <td bordercolor="#000000">
    <a class="item3 arrow" href="javascript:void(0)">Product Information<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>

    <div style="border: 2px; #FFFFFF" class="section">

    <a class="item2" href="<?php echo $tech_url; ?>"> Tech Sheet - <?php echo $techsheet; ?> </a>
    <a class="item2" href="<?php echo $broch_url; ?>"> Product Brochure - <?php echo $brochure; ?> </a>
    <a class="item2" href="/howtobuy.html">How to Buy</a>

    </div>
    <a class="item3 arrow" href="javascript:void(0)">Drivers & Downloads<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="<?php echo $soft_url; ?>">Software - <?php echo $soft; ?></a>

    <a class="item2" href="/products.html">Product Information</a>
    </div>
    <a class="item3 arrow" href="javascript:void(0)">Manuals & Specifications<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="<?php echo $manual_url; ?>"> Manual - <?php echo $manual; ?> </a>
    <a class="item2" href="/trouble.html">FAQs</a>
    </div>
    <a class="item3 arrow" href="">Certifications<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>

    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/certs.html">Partner Certifications</a>
    </div>
    <a class="item3 arrow" href="javascript:void(0)">Support & Service<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/techsupt.html">Contact Tech Support</a>
    <a class="item2" href="/trouble.html">Troubleshooting Tips & FAQs</a>
    <a class="item2" href="/warrantyinfo.html">Warranty Information</a>
    <a class="item2" href="/license.php">Authorize Products</a>
    <a class="item2" href="/registration.php">Register Products</a>
    <a class="item2" href="/services/index.html">Service Programs</a>
    </div>
    <a class="item3 arrow" href="javascript:void(0)">Request Information<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/oem.html">Request Sales Support</a>
    <a class="item2" href="/techsupt.html">Request Technical Support</a>
    </div>
    <a class="item3 arrow" href="javascript:void(0)">Solutions<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/oemsolutions.html">OEM</a>
    <a class="item2" href="/digitalcc.html">Digital Content Creation</a>
    <a class="item2" href="/business.html">Backup</a>
    </div>

    <?php
    if ($db_field == 'url15') {

    <a class="item2" href="<?php echo $url15; ?>"> Special <?php echo $url15; ?> </a>
    }
    ?>
    </td>
    </tr>
    </table>

  6. #6
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: side menu item only shows when DB has item in field

    You need to replace $db_field with whatever database field name you're using. We are assuming that you have some database lookup logic that you haven't shown us. You do have that, right? If not, you have quite a bit of code to add to this to get what you want.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  7. #7
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: side menu item only shows when DB has item in field

    First:
    PHP Code:
    <?php
    if ($db_field == 'url15') {
    <
    class="item2" href="<?php echo $url15; ?>"Special <?php echo $url15?> </a>
    }
    ?>
    Will generate an error - you've got nested <?php tags.
    Second this is going to generate something like
    HTML Code:
    <a class="item2" href=http://www.host.com/special.htm>Special http://www.host.com/special.htm</a>
    Which will appear as Special http;//www,host.com/special.htm - not what you want, I'm sure!
    From the earlier code, you've got a $link, and a $link_url variable for the dynamic links, so I would expect you to have populated $url15 from the database. You need to have $url15, and $url15_url and do something like:
    PHP Code:
    </div>

    <?php
    if (isset($url15) and $url15 != "") {
    //  Check that there is an entry in the database
    // if the url15 field is set to NOT NULL and DEFAULTs to ""
    // you can use if ($url15 !="") {
    echo "<a class=\"item2\" href=\"$url15_url\">Special: $url15</a>";
    }
    ?>
    </td>
    Which should com out as Special: Limited Offer or whatever ...

  8. #8
    bufhal's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Apr 2006
    Posts
    32

    Re: side menu item only shows when DB has item in field

    Thank you all for your help

  9. #9
    bufhal's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Apr 2006
    Posts
    32

    Re: side menu item only shows when DB has item in field

    Thanks you for your time--I am trying to incorporate your PHP into my menu but it is off. Here is a better explanation, I hope this is clearer
    The PHP is in the menu only in the spots that have entries in the database:
    e.g. <a class="item2" href="<?php echo $tech_url; ?>"> Tech Sheet - <?php echo $techsheet; ?> </a>

    I have two fields in MYSQL:
    url15_url(URL) url15(description) both set to NULL-no and default-blank
    (I am using PHP MYSQL and I left nothing in the default)

    Here is the test link:
    http://www.attotech.com/gary_side_test.html

    Below is the bottom section of the menu with bolded area where I am having issues. I need the "Special" to only appear when there is something in the Database fields url15 and url15_url


    <a class="item3 arrow" href="javascript:void(0)">Request Information<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/oem.html">Request Sales Support</a>
    <a class="item2" href="/techsupt.html">Request Technical Support</a>
    </div>
    <a class="item3 arrow" href="javascript:void(0)">Solutions<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/oemsolutions.html">OEM</a>
    <a class="item2" href="/digitalcc.html">Digital Content Creation</a>
    <a class="item2" href="/business.html">Backup</a>
    </div>

    <a class="item3 arrow" href="javascript:void(0)">Special<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <?php
    if (isset($url15) and $url15 != "") {
    // Check that there is an entry in the database
    // if the url15 field is set to NOT NULL and DEFAULTs to ""
    // you can use if ($url15 !="") {
    echo "<a class="/item2/" href="/$url15_url/">Special: $url15</a>";
    }
    ?>
    </div>
    </td>
    </tr>
    </table><!-- #EndLibraryItem -->

    Thank you for your time--If there is something you don't understand, please let me know...

  10. #10
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: side menu item only shows when DB has item in field

    Cool - with that database setting, you should be able to use:
    PHP Code:
    if ($url15 != "") { echo "<a class=\"item2\" href=\"$url15_url\">$url15</a>"; } 
    The only issue is the comparison: != "" means not equal to an empty string - so that may need changing to whatever the default of "blank" generates.
    If it's the string "blank" then you'd need to use
    PHP Code:
    if ($url15 != "blank") { echo "<a class=\"item2\" href=\"$url15_url\">$url15</a>"; } 
    and if all else fails, I'd use that method!
    Note that it's important to use "\" not "/".
    Alternatively you may be able to use
    PHP Code:
    if ($url15 != "blank") { echo "<a class='item2' href='$url15_url'>$url15</a>"; } 
    to avoid confusing slashes!

    That would make the whole piece:
    PHP Code:
    <a class="item3 arrow" href="javascript:void(0)">Request Information<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/oem.html">Request Sales Support</a>
    <a class="item2" href="/techsupt.html">Request Technical Support</a>
    </div>
    <a class="item3 arrow" href="javascript:void(0)">Solutions<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class="item2" href="/oemsolutions.html">OEM</a>
    <a class="item2" href="/digitalcc.html">Digital Content Creation</a>
    <a class="item2" href="/business.html">Backup</a>
    </div>

    <a class="item3 arrow" href="javascript:void(0)">Special<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <?php 
    if ($url15 != "blank") { echo "<a class='item2' href='$url15_url'>$url15</a>"; }
    ?>
    </div>
    </td>
    </tr>
    </table><!-- #EndLibraryItem -->
    which is much more streamlined.
    The "Special" link is the colourful php bit near the end!
    Last edited by DeadMeatGF; 05-13-2006 at 06:27 AM.

  11. #11
    bufhal's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Apr 2006
    Posts
    32

    Re: side menu item only shows when DB has item in field

    Thanks for your replies. I have the field "Special" in the side menu:
    http://www.atto.net/celerityFC-44ES.html
    and it is displaying what is in the DB properly, however, the field "Special" still appears when there is nothing in the DB. I need it to not appear. I tried changing my settings in PHP MYADMIN, but no luck.
    This is what is happening:
    source code live on server
    <a class="item3 arrow" href="javascript:void(0)">Special<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class='item2' href='software/files/manuals/Celerity.pdf?PHPSESSID=c6f8f3c88984a195415aa726a59d17c7'>Hello World</a>
    </div>
    soruce code
    <a class="item3 arrow" href="javascript:void(0)">Special<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <?php
    if ($url15 != "blank") { echo "<a class='item2' href='$url15_url'>$url15</a>"; }
    ?>
    </div>
    Can you please show me how to get the code show the "special" link when the field is populated?
    Thank you very much for any help.

  12. #12
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: side menu item only shows when DB has item in field

    Without seeing the contents of your database, it'd be difficult to go any further.
    If you can change the php (temporarily) to
    PHP Code:
    <?php 
    if ($url15 != "blank") { echo "<a class='item2' href='$url15_url'>$url15</a>"; } 
    echo 
    "\n<br />DEBUG: \$url15 = $url15<br />\nDEBUG: \$url15_url = $url15_url<br />\n";
    ?>
    and post the results for both a Special link that should be there, and one that shouldn't it'd help.
    Cheers ...

  13. #13
    bufhal's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Apr 2006
    Posts
    32

    Re: side menu item only shows when DB has item in field

    almost resolved, please help.
    Thanks for your replies. I have the field "Special" working in the side menu and it is displaying what is in the DB properly, however, the field "Special" still appears when there is nothing in the DB. I tried changing my settings in PHP MYADMIN, but no luck.

    This is what is happening:

    source code live on server
    <a class="item3 arrow" href="javascript:void(0)">Special<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <a class='item2' href='software/files/manuals/Celerity.pdf?PHPSESSID=c6f8f3c88984a195415aa726a59 d17c7'>Hello World</a>
    </div>

    source code

    <a class="item3 arrow" href="javascript:void(0)">Special<img src="/images/arrow3.gif" width="10" height="12" alt="" /></a>
    <div style="border: 2px; #FFFFFF" class="section">
    <?php
    if ($url15 != "blank") { echo "<a class='item2' href='$url15_url'>$url15</a>"; }
    ?>
    </div>

    Can you please show me how to get the code to show the "special" link only when the field is populated?
    Thank you very much for any help, DeadMeat...

  14. #14
    bufhal's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Apr 2006
    Posts
    32

    thank you

    Here is what displays with nothing in the db fields
    http://www.attotech.com/gary_side_test.html
    With something in it shows the links(db content) in the debug window.

    ***I just added the contents in the DB. Now the links show up in the DeBUG
    Last edited by bufhal; 05-15-2006 at 11:37 AM.

  15. #15
    bufhal's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Apr 2006
    Posts
    32

    Re: side menu item only shows when DB has item in field

    Special should not be displaying in the menu



Page 1 of 2 1 2 Last

Tags for this Thread