简体   繁体   English

woocommerce将数据提取到动态下拉列表中

[英]woocommerce pull data into a dynamic dropdown list form

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. 如果下拉列表应该是表格单元格,则td应该在form标记上方。 Make sure you close the cell also. 确保同时关闭电池。

There is issue in HTML formatting. HTML格式存在问题。 The td tag should come before the FORM tag and td should also close right after the form tag to display properly. td标签应位于FORM标签之前,并且td也应在form标签之后立即关闭以正确显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM