Trying to extract data into a dropdown list but no results are showing
<form method="POST" action="city_processProduct.php?action=cityDest">
<td class="label" align="center">
<?php global $wpdb;
// get all countries
$sql1 = "SELECT city_countries_country
FROM city_callingfrom_countries
ORDER BY city_countries_country";
$result1 = $wpdb->get_results($sql1);
?>
<select name="dest[]" size="5" multiple>
<?php global $wpdb;
while($row1 = $wpdb->get_results($result1)) {
extract($row1);
echo"<option value='$row1->$city_countries_country</option> ";
}
?>
</select>
</form>
However when i echo db table row without form it gets results
<?php global $wpdb;
$sql1 = $wpdb->get_results ("SELECT city_countries_country
FROM city_countries
ORDER BY city_countries_country");
foreach ($sql1 as $result){
echo "$result->city_countries_country</br>";
}
?>
You have an orphan table cell in your form code. If the dropdown is supposed to be a table cell the td should be above the form tag. Make sure you close the cell also.
There is issue in HTML formatting. The td tag should come before the FORM tag and td should also close right after the form tag to display properly.
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.