How to set the selected option of <select> tag from the PHP

There is a few ways to do this. The easiest way to do this is in fact really simple, you just need to add a keyword “selected” to the option that you want selected.
For example, if You have something like this:

If we want to have “Samsung” selected:

Pretty easy, don’t you thing so 🙂

Now next thing that we need to do is to make our <select> submit so we could arrange the page accordingly.
To do that, we need to put it inside a <form>, like this:

Depending on your needs and requirements you may need some extra parameters set to the

And that’s it. It has no real use, but it is good to get a grip of how the things work.

Hope someone finds this useful, and also that someone can contribute and make the example better.

Nikola Vasiljevski :