Reputation: 2611
So, I'm retrieving these options from a database
and I need to retrieve the value but I'm getting the text in between the tags
<option></option>
by doing this
$inst = $_POST['inst'];
therefore if I print $inst I get the "IUTIRLA" for the first option but I need the 41
I don't know what I'm doing wrong... this is how I'm printing the html through php
echo "<option value=".$cod_institucion.">".$nombre_institucion."</option>";
Upvotes: 0
Views: 180
Reputation: 20820
here you need to correct php code, as it is not parsing the values properly. Put values under quotes.
echo "<option value='".$cod_institucion."'>".$nombre_institucion."</option>";
Upvotes: 1
Reputation: 9540
Change your code like this
echo '<option value="'. $cod_institucion .'">'. $nombre_institucion .'</option>';
When outputting HTML, it's going to be easier to use single quotes, that way the double quotes inside your HTML don't have to be escaped.
Upvotes: 1
Reputation: 11749
You need to do this...
echo "<option value='".$cod_institucion."'>".$nombre_institucion."</option>";
Upvotes: 0