Jump to content

Lee_Jones

New Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Lee_Jones

  1. Thanks Barand, Sorry its so basic, Im just starting out with PHP. To get the option to be selected accordign to the db value, i a trying the code below,and its not quite working. <?php $id = $_GET["id"]; $sqlSold = "SELECT Sold FROM Products WHERE idProducts = $id;"; $products = [ 'True' => 1, 'False' => 0 ]; ?> <select name="Sold"> <option selected="selected">Choose one</option> <?php foreach($products as $item => $val){ echo "<option value='strtolower($item)' if($val == $products ? 'selected=selected' : ''')>$item</option>"; } ?> </select>
  2. At this point i just want to create the dropdown, it sits inside a form, I have just posted this bit. Sorry if its a bit vague.
  3. I have a column in my db called 'Sold' which is set to Binary. I need a dropdown in my form, that converst the binary into 'True', 'False' for the options, and also selects the one that is set in the db. This is for an edit form, so will then need to adapt it for a add form. This is my code, which doesnt seem to be working <?php $id = $_GET["id"]; $sqlSold = "SELECT Sold FROM Products WHERE idProducts = $id;"; $products = [ 'True' => true, 'False' => false ]; ?> <select name="Sold"> <option selected="selected">Choose one</option> <?php foreach($products as $item){ echo "<option value='strtolower($item)'>$item</option>"; } ?> </select>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.