I´m trying to get which option is in the databse from a <select>, here is my code:
<select name="category" value="<?php echo $category ?>" class="form-control">
<option value="perros">Perro</option>
<option value="gatos">Gato</option>
<option value="peces">Pez</option>
<option value="aves">Ave</option>
<option value="reptiles">Reptil</option>
<option value="roedores">Roedor</option>
<option value="productos">Producto</option>
</select>
my PHP:
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM posts WHERE ID=$id")
or die(mysql_error());
$row = mysql_fetch_array($result);
if($row)
{
$category = $row['category'];
the problem is that it shows the first <option> i have. Thank you
Whole code: http://pastebin.com/2jBjt3SD
value="<?php echo $category ?>". This is open to SQL injections as well.idcome in? Also that could still be an issue, if your values ever contain a'this won't work..