How to get saved data from option select in PHP?
-
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! :)
-
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! :)
-
See PHP Select Option[^].
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);
} -
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);
} -
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'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!
-
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! :)
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.