SHOW SELECTED OPTION VALUE FROM ARRAY & MySQL DATABASE USING PHP
HTML-код
- Опубликовано: 10 сен 2024
- In this tutorial, you will learn how to create an array of categories, display the values inside HTML select box and have selected options pre-defined with PHP and also I will show you how to get selected options from a database using the ID of the record.
Article: raddy.dev/blog...
☕ BuyMeACoffee: www.buymeacoff...
Discounts:
⚡ Hostinger: www.hostg.xyz/...
⚡ Elementor: be.elementor.c...
Recording Equipment:
◾ Microphone: amzn.to/3Ppp8Ok
◾ Shotgun Mic: amzn.to/3IVqIot
◾ Camera: amzn.to/3z0bxpF
◾ Lens: amzn.to/3Pw4s7d
◾ Lighting: amzn.to/3PGXvzW
Computer Gear:
◾ Keyboard: amzn.to/3PGXvzW
◾ Headphones: amzn.to/3PJl9fg
◾ Mouse: amzn.to/3z1TGPf
Connect with me:
◾ Website: www.raddy.dev
◾ Newsletter: www.raddy.co.u...
Hi I need a solution ,
I want to drop down selected value don't show in drop-down after submitting or store in database .. kindly make a video on it
Thank you for this video very much,
Please, a small question, if you can help. I managed to create a table merging content from 2 tables from MySQL database. I added a drop-down list based on the users names in one column, but I'm trying to make another column autofill based on the username for example phone number.
I'm building a form which has contents in the database in 2 separate tables, but I couldn't manage to autofill a column based on username from the other table. Both tables have linked username_id.
Very very thanks brother you solve my big task in my project
👍👍👍👍👍
👊😉
Thanks!
what if i dont use option i just want to show them by group displaying all data
Ive got an assignment where im being asked to echo an image depending on what I select from the database list. is there anyway to do this ?
If I understand correctly, you need to do something like this:
1) Create your Database with the tables and data
2) Create database connection with your favorite language
3) Query the data that you need to display
4) Display the data
5) Close your Database Connection
Just search for "PHP MySQL Select Data" - if you are using PHP and MySQL of course...
I hope this helps!
@@RaddyDev thanks, ive been able to query data and display it. however I want to display and image depending on what the user selects. so example if my user selects apple form the database through my web. I want to display a picture of an apple.in other words I want to link an image. I want to link an image to each selected option. in working with html and php mysql
In this case, you can create a folder called images on your server and then reference the names of the images in the database.
Let's say you have a table called fruit. In that table you might have 3 fields:
id | name | image
1 | apple | apple.jpg
2 | banana | banana.jpg
Then just like you are displaying data from the database, display the image field in an HTML image element.
This is just an example. Obviusly change the variables...
@@RaddyDev Thanks a lot for your help
Exactly what I was looking for!! Thanks a lot!!
hello raddy i have a question i have a dropdown and it shows the selected option value but my teacher doesnt want the selected value on screen and also in the dropdown he only wants it on the the screen when selected if you know what i mean im not great at english (i get the option values from the database)
Like a radio button? The values come from the database and you use a radio buttons to select it?
Nice tutorial
Make some more it is too helpfull
I will do brother. Thank you for watching
Thank you, this tutorial is very helpful. Will implement some of the code in my project.
Sounds good to me. I am glad that you found it useful
Nice tutorial and easy to understand. Good Job.
Bring some more
Thank you! 🦍
Josephale Mayehu
Great video:
How can I display the select statement from the DB on a jS
@@victorsolano9420 You can use PHP inside JS like this:
variableName = "";
Another way you can use is to create a PHP file that does your database query and return as JSON and then maybe use JS to fetch the data and do whatever you want to do with it.
Thank you sir you are helpful
Most welcome
أنا أحبك يا رجل لقد قمت بحل مشكلة كبيرة لي، شكراً لك
Hi great tutorial. would it be possible to get the id associated to the list in the database to display the data without using the get and URL in the browser. Practically you would not expect a user to change the URL to obtain results. I have a database with an array with up to 12 values. on each id. I need to be able to extract values of each array associated to the id.
Is it possible to help me on my ongoing project, where ever I am stuck, may be on charges
I am currently fairly busy and cannot offer one to one help. There must be websites out there where you can hire someone to help you
Hi
How to show the data related to the selected option?
Like this:
We populate two inputs with the first values.
And, if change any input, populate the other input with the context!
You could do that with AJAX if you don't want the page to refresh. Just look up AJAX and MySQL and you will find tons of useful examples. There are a few on w3schools
Can you tel me "i add select form one by one selecting items and create diferent table in that select item"🙄 how can i create that???
Hey, I don't fully understand your question. Try to google it as you'll most likely be able to find a solution quickly. Stackoverflow is full with answers
I have two select dropdowns. One of which are users from the database and others are a theme which they can choose. My users being selected from the database while my themes are a simple select menu (array). After the users select their userId, they can pick a theme and the designChoice column gets updated by the theme which they have selected. I hope you understood it. I had fun playing with that.
That sounds a pretty cool. Good use case I guess. Thank you for watching and I am glad that you found the video useful
if you add another value in the Db will it update in the select ?
The select options are manually stored in an array. You could add them in the database and loop thru them
great tutorial
Thank you!
Hello Raddy
Very nice tutorial.
I have a quick question: How can you populate your dropdown directly from the mySQL database instead of using this line:
$options = array('Comedy', 'Adventure', 'Drama', 'Crime', 'Adult', 'Horror');
Thanks in advance and have a nice day !
This is included in the second half of the video. Just after minute 16:00 is where I start working on it. I hope that it helps and thank you for your comment
@@RaddyDev Thanks for your answer. I double checked your video and the dropdown is populated through an array at line 84 and not from mySQL data.
How can we not manually put an array for $options and get the values from the database ?
Thank You !
Sorry my mistake. Have a look at this example on StackOverflow:
stackoverflow.com/questions/5189662/populate-a-drop-down-box-from-a-mysql-table-in-php
@@RaddyDev I have the same questions too...your video is displaying the array you pointed but not directly form data base...thanks for this info!
@@phiayang5952 The link above has an example with a MySQL query. It's more or less the same, so you might need to try that. Thanks for the question
Thanks bro.......
Thank you for watching, brother!
Very good
Thanks!
Hello, horw r you? It was great learning..
I am great, thank you for asking. How are you doing? Glad that you liked the tutorial
Hi great tutorial!. I was wondering if how to send the selected data from existing database table to a new table in the database using a post method?
Hey, I am glad that you liked the tutorial. To send data on POST you can grab the data with the GET method and then do a MySQL query INSERT. Search for "MySQL post to database" and you will find tons of examples
thx u for your work but you are missing one something . how we can get the value from that combobox when the user interact with the combo box i mean how i can know what value he pick and make action base on it !? thw again ama sorry for bad english keep going
You could look up how to post a value from a drop down and that will hopefully answer your question. You can POST to another page or self post and do whatever you like with the value
Nice video SIR,
I want to display student result from database when they enter their roll no. On website.. kindly guide php code
There are a lot of examples on and videos on this. Have a look at "Retrieve Data From MySQL" and you should get tons of results :)
can i get the code?
Of course: raddy.co.uk/blog/show-selected-option-value-from-array-mysql-db-using-php/
Which is easy JS or PHP??
PHP might be easier to learn, but if you want to do front-end development is better to choose JavaScript. PHP is for only server-side development.
My project is on member association
can you show this tutorial in react??
I haven't started making React videos just yet. Maybe.. maybe in near future. There might a tutorial out there already or stack overflow
Hello im nead helps
What's up?
Can you make from mongodb ?
I haven't done much PHP lately, but I might get back on it. That's purely because most web servers come with mysql for free. MongoDB is pretty nice... i'll consider it