Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6801109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:03:34+00:00 2026-05-26T19:03:34+00:00

I’m making a website, where I should be able to delete some brands from

  • 0

I’m making a website, where I should be able to delete some brands from a database, the brands is stored in categories.

In my form, I have a that echo’s out all the categories in my database.

The next should then contain all brands that is within’ my selected category.

My categories contains a categoryID which is the value of the in the first dropdown – The brands is having it’s own ID, but also having the categoryID, from the category they’re in.

How would you do this? – And can you give an example, it might need javascript or jquery, which is fine with me.

This is my code:

     <form action="deleteBrand.php" method="post">
        <fieldset class="delete">
        <legend>Delete Brand</legend>
        <div>
        <label for="categoryid">Category:<br />
        <?php
            $stmt = $db->prepare("SELECT categoryid, category FROM categories");
            $stmt->execute();
            echo "<select name='categoryid' onchange='this.form.submit()'>";
            while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                echo "<option value='{$row['categoryid']}'>{$row['category']}</option>";
            }
            echo "</select>";
        ?>
        </label>
        </div>
        <div>
        <label for="brand">Brand Name:<br />
        <?php

            $stmt = $db->prepare("SELECT brands.id, brand FROM brands WHERE brands.categoryid = ")
        ?>
        </label>
        </div>
        <div>
        <input type="submit" value="Delete Brand" />
        </div>
        </fieldset>
        </form>

I’m still missing the last dropdown, but if I just can get the value from the selected item from the first dropdown, into a variable, it shouldn’t be hard for the rest of the code!

Thank you a lot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:03:34+00:00Added an answer on May 26, 2026 at 7:03 pm

    The below code is an example of how you can get the selected option value for a dropdown box. Depending on your needs, you can either preload your category id->brand mappings into a javascript variable that you can refer to, or use an ajax request to get the appropriate brands for your second combo box on demand, when the box is clicked.

    <script>
    function getSelected(obj)
    {
        alert(obj.options[obj.selectedIndex].value);
    
        // Now use AJAX or preloaded variable to figure out 
        // what brands map to this category, and populate
        // your second combobox
    }
    </script>
    
    <form action="deleteBrand.php" method="post">
    <label for="categoryid">Category:<br />
    <select name='categoryid' onchange=getSelected(this)>
    <option value="1">A</option>
    <option value="2">B</option>
    <option value="3">C</option>
    </select>
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a reasonable size flat file database of text documents mostly saved in
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.