DanSpedey DanSpedey - 4 months ago 44
HTML Question

Using PHP to load entered form option

I am trying to make it so when the filtered options are entered when the page reloads it has the previously entered options. Image: https://i.gyazo.com/ea334fda79c6a8a1223716ed186d0dfe.png

Here is the current code: (Sorry it is messy, currently just learning web development)

Body: http://hastebin.com/ofiqucayuf.bash The format messed up in here so I think it must be some syntax error.

The last change now makes it so it goes to Sold rather than For Sale


Enclose O & 1 in single quotes. It will work.

Modified Code

<select class="form-control" name="status">
    <option value='1 OR Sold = 0'
    <?php if ($_POST["status"] == "1 OR Sold = 0") { 
    echo "selected"; }; ?>>All Paintings</option>";
    <option value='0' <?php if ($_POST["status"] == '0') {echo "selected"; }; ?>>For Sale</option>
    <option value='1' <?php if ($_POST["status"] == '1') { echo "selected"; }; ?>>Sold</option>