dropdown menu MySQL, PHP

We need a dropdown-menu (<select><option>....), that outputs all the "categories" from the table "categories". When the function/script is called, you can see a dropdownmenu which recursively lists all categories. Like this:

Category 1

-Subcategory 1

-Subcategory 2

--SubSubCategory 1

Category 2

This function/script will be placed on already existing page that is used to edit rows in the table "files". (for example [url removed, login to view] is used to call the row with the 'id' field set to 1). You get the idea.

So, what this piece of code needs to do besides listing all the categories inside a dropdownmenu, is to check what category, the current row that is being edited, is belonging to - And assign the attribute <option SELECTED> to that category name.

All entrys in the "files" table, has a 'category_id' field, that is linking the file to a category from the "category" table

Here is an example of the two tables, and how they look, and a User-Scenario of the achievment of this piece of code.

Table: Category

ID | parent_ID | name

1 | 0 | Category 1

2 | 1 | Category 1 - Part 1

3 | 1 | Category 1 - Part 2

Table: Files

ID | category_ID | name

1 | 2 | [url removed, login to view]

2 | 2 | [url removed, login to view]

3 | 3 | [url removed, login to view]

So, when editing the row with '[url removed, login to view]' (id=1), the dropdownmenu should already have selected what corresponds to category_ID=2, in other words; <option selected> Category 1 - Part 1 </option>

This should be very easy, and just to sum things up:

There is already a piece of code, named [url removed, login to view], that through text-fields gives the user the option to update the field 'name' on the row called to edit. So what this project will add, is a dropdownmenu that tells the user what category the file is allready in, (if it doesn't have a category assigned, the user should be able to assign one through the dropdownmenu) and then put that category as <option SELECTED>, so the user know what category the file belongs to.

Looking forward to be hearing from you.



Just to show what the final output should be like, when we edit mIRC.exe

<option value ="1">Category 1</option>
<option value ="2" SELECTED>...Category 1 - Part 1</option>
<option value ="3">...Category 1 - Part 2</option>

Note that the VALUE is set to the 'category_ID', so when updating the form, these values are sent.

Skills: PHP

See more: menu mysql, dropdown menu mysql, php menu mysql, dropdown mysql, menu php mysql, drop menu php mysql, mysql php drop menu, menu mysql php, php mysql drop menu, drop menu mysql, mysql php menu, dropdown menu php, mysql php dropdown, php drop select mysql, drop menu mysql php, php mysql menu, php mysql drop list, dropdown menu php mysql, dropdown mysql php, drop mysql, php drop box mysql, php mysql drop table fields, php drop list mysql, select option selected mysql, dropdown menu mysql php

About the Employer:
( 12 reviews ) 1169, Norway

Project ID: #245014

Awarded to:


I understand completely your request about this dropdown form field from DB. No problems to be made that way - get all options from DB and set "selected". Contact me at PMB if you need any more info or want me to do th More

$30 USD in 1 day
(65 Reviews)

6 freelancers are bidding on average $58 for this job


Sir, this is simple task and i have already similar functions written. Thank you and looking forward to your answer.

$30 USD in 0 days
(38 Reviews)

can you show the [login to view URL] working?

$30 USD in 1 day
(107 Reviews)

Can do this, Please check PMB

$30 USD in 0 days
(15 Reviews)

Hi. This is easy! Please check PMB.

$200 USD in 1 day
(7 Reviews)

This can be completed within the day. Once approved for this project.

$30 USD in 0 days
(0 Reviews)