Results 1 to 7 of 7

Thread: Quick Help needed (PHP/MYSQL coding)

  1. #1
    Senior Member
    Join Date
    Oct 2004
    Posts
    522
    Thanks
    0
    Thanked
    0 times in 0 posts

    Quick Help needed (PHP/MYSQL coding)

    I am importing data from a table to populate a drop down menu, is there a way to hide the drop down menu if the particular field I am importing data from is empty?


    Thanks

  2. #2
    Member
    Join Date
    Jul 2006
    Posts
    83
    Thanks
    0
    Thanked
    10 times in 9 posts

    Re: Quick Help needed (PHP/MYSQL coding)

    You will have to use Javascript and use it to change the CSS visibility of the dropdown to hidden if, say, dropdownmenu.title is "EMPTY" or some other string you can pass using PHP.
    The alternative is to use rewrite everything using ASP.
    If you have trouble with the code, paste the bits you have trouble with and people here will help you write it up.

  3. #3
    www.dougmcdonald.co.uk
    Join Date
    May 2007
    Location
    Bath
    Posts
    523
    Thanks
    5
    Thanked
    20 times in 20 posts
    • DougMcDonald's system
      • Motherboard:
      • Asus P5B Deluxe
      • CPU:
      • Inter Core 2 Duo E6600
      • Memory:
      • 2 x 2GB - Geil Black Dragon PC6400
      • Storage:
      • 2 x 400GB Samsung Spinpoints (Running in Matrix array) 100GB @ RAID0 + 300GB @ RAID1
      • Graphics card(s):
      • BFG nVidia 8800GTS 320MB OC2
      • PSU:
      • Corsair HX520W modular
      • Case:
      • Lian-Li PC7 II Plus
      • Monitor(s):
      • LG 17" Flat Thingy
      • Internet:
      • Crappy BT 1MB Unreliable wank :s

    Re: Quick Help needed (PHP/MYSQL coding)

    You could use a conditional statement to only write the html output if the sql query returns at least one row.

    So kind of pseudo code:

    $sqlquery = select blah
    $rows = number of rows returned by $sqlquery

    if $rows > 0 {
    //start dropdown, note that this only happens when one row or more is returned
    print <select>

    for each row {
    print <option>value</option>
    }

    print </select>
    }

  4. #4
    Mostly Me Lucio's Avatar
    Join Date
    Mar 2007
    Location
    Tring
    Posts
    5,163
    Thanks
    443
    Thanked
    448 times in 351 posts
    • Lucio's system
      • Motherboard:
      • Gigabyte GA-970A-UD3P
      • CPU:
      • AMD FX-6350 with Cooler Master Seldon 240
      • Memory:
      • 2x4GB Corsair DDR3 Vengeance
      • Storage:
      • 128GB Toshiba, 2.5" SSD, 1TB WD Blue WD10EZEX, 500GB Seagate Baracuda 7200.11
      • Graphics card(s):
      • Sapphire R9 270X 4GB
      • PSU:
      • 600W Silverstone Strider SST-ST60F
      • Case:
      • Cooler Master HAF XB
      • Operating System:
      • Windows 8.1 64Bit
      • Monitor(s):
      • Samsung 2032BW, 1680 x 1050
      • Internet:
      • 16Mb Plusnet

    Re: Quick Help needed (PHP/MYSQL coding)

    Easiest way I can think of would be to slap a simply if statement around your dropdown with it testing the number of rows.

    If numrows!=0 -> display code for dropdown.

    You can easily slide it into exsisting code without having to re-do a whole section then.

  5. #5
    www.dougmcdonald.co.uk
    Join Date
    May 2007
    Location
    Bath
    Posts
    523
    Thanks
    5
    Thanked
    20 times in 20 posts
    • DougMcDonald's system
      • Motherboard:
      • Asus P5B Deluxe
      • CPU:
      • Inter Core 2 Duo E6600
      • Memory:
      • 2 x 2GB - Geil Black Dragon PC6400
      • Storage:
      • 2 x 400GB Samsung Spinpoints (Running in Matrix array) 100GB @ RAID0 + 300GB @ RAID1
      • Graphics card(s):
      • BFG nVidia 8800GTS 320MB OC2
      • PSU:
      • Corsair HX520W modular
      • Case:
      • Lian-Li PC7 II Plus
      • Monitor(s):
      • LG 17" Flat Thingy
      • Internet:
      • Crappy BT 1MB Unreliable wank :s

    Re: Quick Help needed (PHP/MYSQL coding)

    Isn't that what I've suggested in the previous post?

  6. #6
    Mostly Me Lucio's Avatar
    Join Date
    Mar 2007
    Location
    Tring
    Posts
    5,163
    Thanks
    443
    Thanked
    448 times in 351 posts
    • Lucio's system
      • Motherboard:
      • Gigabyte GA-970A-UD3P
      • CPU:
      • AMD FX-6350 with Cooler Master Seldon 240
      • Memory:
      • 2x4GB Corsair DDR3 Vengeance
      • Storage:
      • 128GB Toshiba, 2.5" SSD, 1TB WD Blue WD10EZEX, 500GB Seagate Baracuda 7200.11
      • Graphics card(s):
      • Sapphire R9 270X 4GB
      • PSU:
      • 600W Silverstone Strider SST-ST60F
      • Case:
      • Cooler Master HAF XB
      • Operating System:
      • Windows 8.1 64Bit
      • Monitor(s):
      • Samsung 2032BW, 1680 x 1050
      • Internet:
      • 16Mb Plusnet

    Re: Quick Help needed (PHP/MYSQL coding)

    Quote Originally Posted by DougMcDonald View Post
    Isn't that what I've suggested in the previous post?
    Not sure, your code seemed a little odd with all those "prints" in it, so I wasn't sure quite what you were getting at

  7. #7
    www.dougmcdonald.co.uk
    Join Date
    May 2007
    Location
    Bath
    Posts
    523
    Thanks
    5
    Thanked
    20 times in 20 posts
    • DougMcDonald's system
      • Motherboard:
      • Asus P5B Deluxe
      • CPU:
      • Inter Core 2 Duo E6600
      • Memory:
      • 2 x 2GB - Geil Black Dragon PC6400
      • Storage:
      • 2 x 400GB Samsung Spinpoints (Running in Matrix array) 100GB @ RAID0 + 300GB @ RAID1
      • Graphics card(s):
      • BFG nVidia 8800GTS 320MB OC2
      • PSU:
      • Corsair HX520W modular
      • Case:
      • Lian-Li PC7 II Plus
      • Monitor(s):
      • LG 17" Flat Thingy
      • Internet:
      • Crappy BT 1MB Unreliable wank :s

    Re: Quick Help needed (PHP/MYSQL coding)

    well, print/echos are just like ending the php code, inserting plain html and then opening the php code again.

    I prefer it because it keeps the code inline in a more sensible manner imo

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Very strange problem, help needed.
    By M C STORM in forum Help! Quick Relief From Tech Headaches
    Replies: 4
    Last Post: 16-06-2004, 09:59 PM
  2. quick response needed...
    By 5lab in forum General Discussion
    Replies: 18
    Last Post: 18-05-2004, 04:15 PM
  3. Replies: 3
    Last Post: 29-04-2004, 07:03 PM
  4. Quick and easy PHP help needed chaps
    By Kezzer in forum Software
    Replies: 20
    Last Post: 23-02-2004, 07:45 PM
  5. Quick Question need a quick answer?
    By ©DinG© in forum PC Hardware and Components
    Replies: 8
    Last Post: 06-02-2004, 12:06 PM

Posting Permissions

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