php - 无法使用 MYSQL 数据库项目填充保管箱

标签 php mysql

多年来我一直在尝试填充此下拉列表,它显示的项目只是不在下拉列表内。 有任何想法吗? :)

<?php 
     $html='';
     $html.='<select>';
     $queryExercise="SELECT exerciseName FROM workouts";
     $queryExercise=mysql_query($queryExercise);
     while($result=mysql_fetch_array($queryExercise))
     {
      $exerciseName=$result['exerciseName'];
      echo '<option value="'.$exerciseName.'">'.$exerciseName.'</option>';
     }
     $html.='</select>';
     echo $html;
    ?>

最佳答案

您的查询完美运行,但问题是连接生成的下拉列表 html。

由于您要连接 $html 中的所有内容,因此您需要再次将下拉列表的结果连接到 $html ,然后 echo $html

尝试下面的代码:

<?php 
     $html ='<select>';
     $queryExercise="SELECT exerciseName FROM workouts";
     $queryExercise=mysql_query($queryExercise);
     while($result=mysql_fetch_array($queryExercise))
     {
      $exerciseName=$result['exerciseName'];
      $html .= '<option value="'.$exerciseName.'">'.$exerciseName.'</option>';
     }
     $html.='</select>';
     echo $html;
?>

关于php - 无法使用 MYSQL 数据库项目填充保管箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40713321/

相关文章:

javascript - PHP-Ajax : Display a specific row information from a while loop by clicking on a link

mysql - 存储平均正常运行时间数据的最佳方法

mysql - 在Mysql中搜索相似的字符串

php - 使用 mysql 验证登录

php - 序列化(数据)的哪个mysql列类型?

php - Symfony - 使用服务工厂还是服务配置器更好?

php - 将两个查询合并为单个查询

php - Laravel 5 Eloquent 地查询半正矢公式

php - osCommerce:如何将 'quantity' 字段从仅允许数字更改为所有字符?

mysql - 我如何才能从相同的 id_category 和 id_service 中仅获取行及其最大日期