我尝试使用数据库中的一些值填充下拉菜单。 在我使用“Select DISTINCT”后,它不会检索数据库中的所有数据。
这是我的 php 代码
<?
$sqlretrive = mysql_query("Select DISTINCT type from
tb_shuffle_table where status = 1 and user_id = $user_id");
$rows = mysql_fetch_array($sqlretrive)
?>
这是我的 html 代码
<select name="type" id="type" class="form-control" required >
<option value="">Please Select Question Type</option>
<? while ($row = mysql_fetch_array($sqlretrive)){ ?>
<option value="<?=$row['type']?>">
<?=$row['type']?>
</option>
<? }?>
</select></td>
{这是我的数据库表} 1
最佳答案
根据您的评论,使用选择不同类型...
,如果它确实过滤掉了1
,那么很容易理解特定记录与您的不匹配提供了如下所示的 WHERE
条件。
where status = 1 and user_id = $user_id
关于php - 我的 'Select DISTINCT' 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31984216/