How to get / populate select option values from database using PHP

preview_player
Показать описание
How to populate HTML select options from the values fetched from database using the PHP code is explained with example. Create Select drop down menu with values taken from database. I have used html, ajax, php & sql codes.

For create database "drinks" with table "list" run the following code in database SQL.

CREATE DATABASE drinks;

CREATE TABLE list (
id INT(2) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
D_Type VARCHAR(10) NOT NULL,
D_Name VARCHAR(10) NOT NULL
);

INSERT INTO list (id, D_Type, D_Name) VALUES ('', 'Cold', 'Apple Juce');
INSERT INTO list (id, D_Type, D_Name) VALUES ('', 'Hot', 'Coffee');
INSERT INTO list (id, D_Type, D_Name) VALUES ('', 'Cold', 'Kiwi Juce');
INSERT INTO list (id, D_Type, D_Name) VALUES ('', 'Hot', 'Tea');

Source code path:
Рекомендации по теме
Комментарии
Автор

I got exactly this assignment from my internship. it was horror but you helped me...thank you very much....KEEP GOING

hedrobc
Автор

Thank You bhai.. helpful video... great keep helping

someshwarghorpade
Автор

you are the best after 100 video i found this + worked perfectly

minasseracnr
Автор

How does it use for 3 select options. Can you help me.

chiranthaekanayake
Автор

Pls make video for select drop-down list using Ajax without JSON or jQuery and pls make video for database. if I wants to add value for select drop-down without select query...

poojabharti
Автор

Thank Sir. this is very helpful. Can I also store and display multiple values from the database ?

ahmedabdiguure
Автор

I dont want using ajax or jquery i dont like javascript but php only how to get the selected value using php, can I just switch case?

putinninovacuna
Автор

How to submit in other table to store these values? Thanks help me

FreeTutorials
Автор

Hi, do you know what could cause an error for this line $val = $_GET["value"]; in the php file?

I got this error.

Warning: Undefined array key "value" in on line 8

Select Drink

jonellecorridon
Автор

Sir how to use this in netbean while using JDBC HTML java

vaibhavgaikwad
Автор

your source code link does not work any more or at least not for me :(

JasonPurkiss
Автор

$val= $_GET["value"]; this line cause an Error

LeonardoGrinn
Автор

bro it not working an error was displaying

saitejateja
Автор

Where's the source code your domain has expired

afretoon