this is my coding
$sql="SELECT code,rate, name FROM price_detail WHERE ref_no='VACC'";
echo "<select onchange='vaccines(this)' name='student' value='0'><option> Select Vaccines Type</option>";
foreach ($dbh->query($sql) as $row){
echo "<option value=$row[rate]>$row[name]</option>";
}
echo "</select>";
here i need $row['name'] for $row['rate'] i take values of option
how can i retrive ['name']
You can't use table notation directly into string.
You can use concatenation like this :
echo '<option value="'.$row['rate'].'">'.$row['name'].'</option>';
Or wrap your table variables between {}
echo "<option value='{$row['rate']}'>{$row['name']}</option>";
Don't forget the quotes for the html value
parameter, and the quotes for the index of the table.
Note : If you don't use quotes for the table index, it will try to match a constant and will fallback assuming it is a string if no constant has been found.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.