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...

Комментарии • 68

  • @sainikbagri8876
    @sainikbagri8876 2 года назад +1

    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

  • @mominadil2279
    @mominadil2279 2 года назад +2

    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.

  • @faizanrehmani2564
    @faizanrehmani2564 2 года назад

    Very very thanks brother you solve my big task in my project
    👍👍👍👍👍

  • @agustinavendano4918
    @agustinavendano4918 2 года назад +1

    Thanks!

  • @jonjoncandare4649
    @jonjoncandare4649 2 года назад

    what if i dont use option i just want to show them by group displaying all data

  • @kelvinowusu7083
    @kelvinowusu7083 4 года назад +2

    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 ?

    • @RaddyDev
      @RaddyDev  4 года назад +1

      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!

    • @kelvinowusu7083
      @kelvinowusu7083 4 года назад

      @@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

    • @RaddyDev
      @RaddyDev  4 года назад +2

      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...

    • @kelvinowusu7083
      @kelvinowusu7083 4 года назад +1

      @@RaddyDev Thanks a lot for your help

  • @athithyaparamesh8251
    @athithyaparamesh8251 2 года назад +1

    Exactly what I was looking for!! Thanks a lot!!

  • @youneshessani9195
    @youneshessani9195 Год назад

    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)

    • @RaddyDev
      @RaddyDev  Год назад

      Like a radio button? The values come from the database and you use a radio buttons to select it?

  • @karanjoshi8220
    @karanjoshi8220 4 года назад +2

    Nice tutorial
    Make some more it is too helpfull

    • @RaddyDev
      @RaddyDev  4 года назад

      I will do brother. Thank you for watching

  • @wordpressidee
    @wordpressidee 3 года назад

    Thank you, this tutorial is very helpful. Will implement some of the code in my project.

    • @RaddyDev
      @RaddyDev  3 года назад +2

      Sounds good to me. I am glad that you found it useful

  • @jjosephale
    @jjosephale 4 года назад +1

    Nice tutorial and easy to understand. Good Job.
    Bring some more

    • @RaddyDev
      @RaddyDev  4 года назад

      Thank you! 🦍

    • @victorsolano9420
      @victorsolano9420 4 года назад

      Josephale Mayehu
      Great video:
      How can I display the select statement from the DB on a jS

    • @RaddyDev
      @RaddyDev  4 года назад

      @@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.

  • @mr.bekzod9989
    @mr.bekzod9989 Год назад

    Thank you sir you are helpful

  • @homestudio7866
    @homestudio7866 3 дня назад

    أنا أحبك يا رجل لقد قمت بحل مشكلة كبيرة لي، شكراً لك

  • @AuriffYusuf
    @AuriffYusuf 2 года назад

    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.

  • @mkajiwala1
    @mkajiwala1 2 года назад

    Is it possible to help me on my ongoing project, where ever I am stuck, may be on charges

    • @RaddyDev
      @RaddyDev  2 года назад

      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

  • @silviopontesx
    @silviopontesx 3 года назад

    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!

    • @RaddyDev
      @RaddyDev  3 года назад

      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

  • @suchinthasuriyaarachchi8184
    @suchinthasuriyaarachchi8184 3 года назад

    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???

    • @RaddyDev
      @RaddyDev  3 года назад

      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

  • @omniversal4739
    @omniversal4739 4 года назад

    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.

    • @RaddyDev
      @RaddyDev  4 года назад +1

      That sounds a pretty cool. Good use case I guess. Thank you for watching and I am glad that you found the video useful

  • @madmattermassive
    @madmattermassive 3 года назад

    if you add another value in the Db will it update in the select ?

    • @RaddyDev
      @RaddyDev  3 года назад

      The select options are manually stored in an array. You could add them in the database and loop thru them

  • @Siblingsfunmoments
    @Siblingsfunmoments 2 года назад

    great tutorial

  • @jeanbeaudet3249
    @jeanbeaudet3249 4 года назад +3

    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 !

    • @RaddyDev
      @RaddyDev  4 года назад

      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

    • @jeanbeaudet3249
      @jeanbeaudet3249 4 года назад +2

      @@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 !

    • @RaddyDev
      @RaddyDev  4 года назад +1

      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

    • @phiayang5952
      @phiayang5952 3 года назад +1

      @@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!

    • @RaddyDev
      @RaddyDev  3 года назад

      @@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

  • @sqtrailer7450
    @sqtrailer7450 3 года назад

    Thanks bro.......

    • @RaddyDev
      @RaddyDev  3 года назад +1

      Thank you for watching, brother!

  • @mkajiwala1
    @mkajiwala1 2 года назад

    Very good

  • @mkajiwala1
    @mkajiwala1 2 года назад

    Hello, horw r you? It was great learning..

    • @RaddyDev
      @RaddyDev  2 года назад

      I am great, thank you for asking. How are you doing? Glad that you liked the tutorial

  • @jevarnotice6999
    @jevarnotice6999 3 года назад

    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?

    • @RaddyDev
      @RaddyDev  3 года назад

      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

  • @helmiboubaker2742
    @helmiboubaker2742 3 года назад

    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

    • @RaddyDev
      @RaddyDev  3 года назад +1

      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

  • @maliksaab9736
    @maliksaab9736 3 года назад

    Nice video SIR,
    I want to display student result from database when they enter their roll no. On website.. kindly guide php code

    • @RaddyDev
      @RaddyDev  3 года назад

      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 :)

  • @nayanaalur1208
    @nayanaalur1208 4 года назад +1

    can i get the code?

    • @RaddyDev
      @RaddyDev  4 года назад +1

      Of course: raddy.co.uk/blog/show-selected-option-value-from-array-mysql-db-using-php/

    • @nayanaalur1208
      @nayanaalur1208 4 года назад

      Which is easy JS or PHP??

    • @RaddyDev
      @RaddyDev  4 года назад

      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.

  • @mkajiwala1
    @mkajiwala1 2 года назад

    My project is on member association

  • @ulfinawakjira1977
    @ulfinawakjira1977 2 года назад

    can you show this tutorial in react??

    • @RaddyDev
      @RaddyDev  2 года назад

      I haven't started making React videos just yet. Maybe.. maybe in near future. There might a tutorial out there already or stack overflow

  • @ALSTATH
    @ALSTATH 3 года назад

    Hello im nead helps

  • @sukmawijaya4144
    @sukmawijaya4144 2 года назад

    Can you make from mongodb ?

    • @RaddyDev
      @RaddyDev  2 года назад +1

      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