选项标记

时间:2016-01-19 17:48:26

标签: java php mysql

$sql1 = "SELECT c.comm FROM enquiry e JOIN comments c ON e.id = c.enquiryId where e.id = '$memberId' AND e.cmpId = '$companyId'";    
$result1 = mysqli_query($conn, $sql1);
echo "<select class='form-control' name='comment'>";
    while($row1 = mysqli_fetch_array($result1, MYSQLI_ASSOC)){
        echo "
  <option value='".$row1['comm']."'>".$row1['comm']."</option>

    </select>";
 }

我想在选项中回显c.comm的所有值,但在获取ptint时只有一个值 请帮忙 As  u can see all the values of column are getting print but only one value is inside the option tag, i want all values in the option tag

2 个答案:

答案 0 :(得分:3)

将结束</select>标记放在while循环之后。

答案 1 :(得分:1)

尝试编写select标签,如下所示:

  <select class="form-control" name="comment">
    $sql1 = "SELECT c.comm FROM enquiry e JOIN comments c ON e.id =   c.enquiryId where e.id = '$memberId' AND e.cmpId = '$companyId'";    
    $result1 = mysqli_query($conn, $sql1);
   while($row1 = mysqli_fetch_array($result1, MYSQLI_ASSOC)){
     echo "<option value='".$row1['comm']."'>".$row1['comm']."</option>

  }
 </select>