Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. How to get saved data from option select in PHP?

How to get saved data from option select in PHP?

Scheduled Pinned Locked Moved Web Development
phpdatabasemysqlcomtutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    imbruceter
    wrote on last edited by
    #1

    I'm quite new to PHP. I have a selection dropdown, which sends the data to the phpmyadmin database. This works fine, but I'd like it to be selected as default when I'm opening it again. Here is how my code currently looks like:

    What I have tried:

    I basically just inserted "selected" into it, but it's not the correct way, because every single option is shown as "selected". Here is an image about the frontend: https://i.imgur.com/I2cXYrN.png[^] Does anyone know how to make it to work? Thank you for being here! :)

    L S 2 Replies Last reply
    0
    • I imbruceter

      I'm quite new to PHP. I have a selection dropdown, which sends the data to the phpmyadmin database. This works fine, but I'd like it to be selected as default when I'm opening it again. Here is how my code currently looks like:

      What I have tried:

      I basically just inserted "selected" into it, but it's not the correct way, because every single option is shown as "selected". Here is an image about the frontend: https://i.imgur.com/I2cXYrN.png[^] Does anyone know how to make it to work? Thank you for being here! :)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      See PHP Select Option[^].

      I 1 Reply Last reply
      0
      • L Lost User

        See PHP Select Option[^].

        I Offline
        I Offline
        imbruceter
        wrote on last edited by
        #3

        Thank you for your answer! I have read on many pages about this issue, but not gonna lie, this looks like chinese for me. I'm uploading the data to the phpmyadmin database through this line:

        $category_query = "SELECT * FROM categories";
        $categories = mysqli_query($connection, $category_query);
        if (isset($_GET['id'])) {
        $id = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
        }

        L 1 Reply Last reply
        0
        • I imbruceter

          Thank you for your answer! I have read on many pages about this issue, but not gonna lie, this looks like chinese for me. I'm uploading the data to the phpmyadmin database through this line:

          $category_query = "SELECT * FROM categories";
          $categories = mysqli_query($connection, $category_query);
          if (isset($_GET['id'])) {
          $id = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
          }

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Quote:

          this looks like chinese for me.

          Then I suggest you spend time studying PHP before trying to use advanced topics: see PHP Tutorial[^]

          I 1 Reply Last reply
          0
          • L Lost User

            Quote:

            this looks like chinese for me.

            Then I suggest you spend time studying PHP before trying to use advanced topics: see PHP Tutorial[^]

            I Offline
            I Offline
            imbruceter
            wrote on last edited by
            #5

            I've spent the past month to get this small project to work and other than that, I have nothing to do with PHP. So, in order to fix a few small issues, I really don't want to learn coding in PHP. That's why I made a gamble and post it here. Thank you for your time and your tip!

            1 Reply Last reply
            0
            • I imbruceter

              I'm quite new to PHP. I have a selection dropdown, which sends the data to the phpmyadmin database. This works fine, but I'd like it to be selected as default when I'm opening it again. Here is how my code currently looks like:

              What I have tried:

              I basically just inserted "selected" into it, but it's not the correct way, because every single option is shown as "selected". Here is an image about the frontend: https://i.imgur.com/I2cXYrN.png[^] Does anyone know how to make it to work? Thank you for being here! :)

              S Offline
              S Offline
              Sandrahdes
              wrote on last edited by
              #6

              A super global variable called $_SERVER["PHP SELF"] returns the name of the script that is presently running. As a result, rather than navigating to another page, the $_SERVER["PHP SELF"] transmits the form data to the current page. The user will receive error notifications in this manner on the same page as the form. On page load, you can leave the table's property set to display:none, and when the button is clicked, run a function to change the table's display to block.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups