$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 '<opti开发者_JS百科on>'.$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!
Why not grouping your SQL-query?
"SELECT `batch` FROM $dept GROUP BY `batch`";
$sql2 = "SELECT batch FROM $dept GROUP BY `batch`";
The GROUP BY
clause will cause all the rows to be grouped by the batch
column effectively only returning one row for each batch
value.
精彩评论