限制下拉列表中相同值的输出
$dept = $_POST['dept'];
$sql2 = "SELECT batch FROM $dept";
$result2 = mysql_query($sql2);
echo '<form method="post" id="try2" action="pillar.php">';
echo 'Select Batch: ';
echo '<select name="batch" id="batch">';
while($q = mysql_fetch_assoc($result2))
{
$batch = $q['batch'];
echo '<option>'.$batch.'</option>';
}
echo '</select><br><br>';
echo '<input type="submit">';
.如何限制数据的输出与使用 select 语句从数据库检索到的值相同?请帮忙!提前致谢!
$dept = $_POST['dept'];
$sql2 = "SELECT batch FROM $dept";
$result2 = mysql_query($sql2);
echo '<form method="post" id="try2" action="pillar.php">';
echo 'Select Batch: ';
echo '<select name="batch" id="batch">';
while($q = mysql_fetch_assoc($result2))
{
$batch = $q['batch'];
echo '<option>'.$batch.'</option>';
}
echo '</select><br><br>';
echo '<input type="submit">';
.how can i restrict the outputting of data with the same value that was retrieved from the database using the select statement? help pls! Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不对 SQL 查询进行分组?
Why not grouping your SQL-query?
GROUP BY
子句将导致所有行按batch
列进行分组,实际上只为每个batch
值返回一行。The
GROUP BY
clause will cause all the rows to be grouped by thebatch
column effectively only returning one row for eachbatch
value.