如何防止表格中的重复记录:
<select name="web_site">
<?php
$query = $db->query("SELECT * FROM `work`");
while ($row = mysql_fetch_array($query)) {
print '<option value="'.$row['id'].'">'.$row['title'].'</option>';
}
?>
</select>
答案 0 :(得分:0)
$query = $db->query("SELECT * FROM `work` group by title");
答案 1 :(得分:0)
<select name="web_site">
<?php
$query = $db->query("SELECT DISTINCT title FROM `work`");
while ($row = mysql_fetch_array($query)) {
print '<option value="'.$row['id'].'">'.$row['title'].'</option>';
}
?>
</select>