Jump to content

Help with dependant dropdowns in PHP/MySql


dvdflashbacks

Recommended Posts

Hi there,

 

I have a dynamic dropdown that grabs data from just the category ids and displays everything to a results page.  I am stuck on figuring out how to add onto this drop down so that I can select the category and then another parameter.  Can someone help me with this?

 

Here is the current code that I am using:

 

<form action="directoryResults.php" method="get" name="healthDirectory2" id="categorySearch2">
              <select name="categoryName" class="" id="categoryName" onchange="submit()">
                <option value="----- Select a Category -----" <?php if (!(strcmp("----- Select a Category -----", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>----- Select a Category -----</option>
                <option value="Allergists & ENT" <?php if (!(strcmp("Allergists & ENT", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Allergists & ENT</option>
                <option value="Assisted Care & Senior Living" <?php if (!(strcmp("Assisted Care & Senior Living", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Assisted Care & Senior Living</option><option value="Cardiology" <?php if (!(strcmp("Cardiology", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Cardiology</option>
                <option value="Cardiovascular & Thoracic Surgeons" <?php if (!(strcmp("Cardiovascular & Thoracic Surgeons", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Cardiovascular & Thoracic Surgeons</option><option value="Chiropractic & Accupuncture" <?php if (!(strcmp("Chiropractic & Accupuncture", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Chiropractic & Accupuncture</option>
                <option value="Clinical Research" <?php if (!(strcmp("Clinical Research", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Clinical Research</option>
                <option value="Dentistry & Oral Health" <?php if (!(strcmp("Dentistry & Oral Health", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Dentistry & Oral Health</option><option value="Dermatology" <?php if (!(strcmp("Dermatology", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Dermatology</option>
                <option value="Diagnostic Imaging" <?php if (!(strcmp("Diagnostic Imaging", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Diagnostic Imaging</option>
                <option value="Emergency Numbers" <?php if (!(strcmp("Emergency Numbers", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Emergency Numbers</option>
                <option value="Endocrinology" <?php if (!(strcmp("Endocrinology", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Endocrinology</option><option value="Family Practice" <?php if (!(strcmp("Family Practice", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Family Practice</option>
                <option value="Fitness & Weight Management" <?php if (!(strcmp("Fitness & Weight Management", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Fitness & Weight Management</option><option value="Gastroenterology" <?php if (!(strcmp("Gastroenterology", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Gastroenterology</option>
                <option value="General Surgery" <?php if (!(strcmp("General Surgery", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>General Surgery</option>
                <option value="Hand Surgery" <?php if (!(strcmp("Hand Surgery", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Hand Surgery</option>
                <option value="Health Departments" <?php if (!(strcmp("Health Departments", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Health Departments</option>
                <option value="Health Products & Equipment" <?php if (!(strcmp("Health Products & Equipment", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Health Products & Equipment</option><option value="Hearing & Audiology" <?php if (!(strcmp("Hearing & Audiology", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Hearing & Audiology</option>
                <option value="Hearing Aids" <?php if (!(strcmp("Hearing Aids", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Hearing Aids</option>
                <option value="Hospice & Home Care" <?php if (!(strcmp("Hospice & Home Care", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Hospice & Home Care</option>
                <option value="Hospitals & Clinics" <?php if (!(strcmp("Hospitals & Clinics", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Hospitals & Clinics</option><option value="Hypnosis" <?php if (!(strcmp("Hypnosis", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Hypnosis</option>
                <option value="Infectious Disease" <?php if (!(strcmp("Infectious Disease", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Infectious Disease</option><option value="Internal Medicine" <?php if (!(strcmp("Internal Medicine", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Internal Medicine</option>
                <option value="Medical Transportation" <?php if (!(strcmp("Medical Transportation", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Medical Transportation</option>
                <option value="Nephrology & Renal Health" <?php if (!(strcmp("Nephrology & Renal Health", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Nephrology & Renal Health</option>
                <option value="Neurology & Neurosurgery" <?php if (!(strcmp("Neurology & Neurosurgery", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Neurology & Neurosurgery</option>
                <option value="Neuropsychology" <?php if (!(strcmp("Neuropsychology", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Neuropsychology</option><option value="Non-profit Organizations" <?php if (!(strcmp("Non-profit Organizations", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Non-profit Organizations</option>
                <option value="Obstetrics & Gynecology" <?php if (!(strcmp("Obstetrics & Gynecology", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Obstetrics & Gynecology</option>
                <option value="Occupational Health Services" <?php if (!(strcmp("Occupational Health Services", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Occupational Health Services</option><option value="Oncology" <?php if (!(strcmp("Oncology", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Oncology</option>
                <option value="Ophthalmology" <?php if (!(strcmp("Ophthalmology", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Ophthalmology</option>
                <option value="Optometry" <?php if (!(strcmp("Optometry", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Optometry</option>
                <option value="Orthopedics & Sports Medicine" <?php if (!(strcmp("Orthopedics & Sports Medicine", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Orthopedics & Sports Med</option>
                <option value="Pain Management" <?php if (!(strcmp("Pain Management", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Pain Management</option>
                <option value="Pediatrics" <?php if (!(strcmp("Pediatrics", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Pediatrics</option>
                <option value="Pharmacies" <?php if (!(strcmp("Pharmacies", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Pharmacies</option>
                <option value="Physical Therapy & Rehabilitation" <?php if (!(strcmp("Physical Therapy & Rehabilitation", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Physical Therapy & Rehab</option>
                <option value="Plastic & Cosmetic Surgery" <?php if (!(strcmp("Plastic & Cosmetic Surgery", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Plastic & Cosmetic Surgery</option>
                <option value="Podiatry" <?php if (!(strcmp("Podiatry", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Podiatry</option>
                <option value="Preventative Medicine" <?php if (!(strcmp("Preventative Medicine", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Preventative Medicine</option>
                <option value="Prosthetics & Orthotics" <?php if (!(strcmp("Prosthetics & Orthotics", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Prosthetics & Orthotics</option>
                <option value="Psychiatry & Mental Health" <?php if (!(strcmp("Psychiatry & Mental Health", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Psychiatry & Mental Health</option>
                <option value="Pulmonology & Sleep Disorders" <?php if (!(strcmp("Pulmonology & Sleep Disorders", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Pulmonology & Sleep Disorders</option>
                <option value="Reproductive Medicine" <?php if (!(strcmp("Reproductive Medicine", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Reproductive Medicine</option>
                <option value="Rheumatology" <?php if (!(strcmp("Rheumatology", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Rheumatology</option>
                <option value="Spas & Massage" <?php if (!(strcmp("Spas & Massage", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Spas & Massage</option>
                <option value="Substance Abuse & Addiction" <?php if (!(strcmp("Substance Abuse & Addiction", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Substance Abuse & Addiction</option>
                <option value="Urology" <?php if (!(strcmp("Urology", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Urology</option>
                <option value="Vascular Surgery" <?php if (!(strcmp("Vascular Surgery", $row_categorySearch['categoryName']))) {echo "selected=\"selected\"";} ?>>Vascular Surgery</option>
              </select>
        </form>

As a side note:

 

Not sure if this matters, but the table that I am trying to pull info from only has one primary key.  The table has an ID field, a category, then city, state, etc.

 

Hope someone can help me out on this, I am really stuck here.

 

Thanks and Happy New Year to everyone!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.