I have a good php script that works. But I need to modify it so the first select option is blank. Can anyone开发者_运维百科 help?
<?php
// connect to MySQL
$query = "SELECT <col> FROM <table>";
$result = mysql_query($query);
?>
<select name="sel" id="sel">
<?php
while($row = mysql_fetch_assoc($result)){
echo "<option>{$row['<col>']}</option>";
}
?>
</select>
Is this what you mean?
<?php
// connect to MySQL
$query = "SELECT <col> FROM <table>";
$result = mysql_query($query);
?>
<select name="sel" id="sel">
<option value="-1"></option>
<?php
while($row = mysql_fetch_assoc($result)){
echo "<option>{$row['<col>']}</option>";
}
?>
</select>
Just make it blank:
<?php
// connect to MySQL
$query = "SELECT <col> FROM <table>";
$result = mysql_query($query);
?>
<select name="sel" id="sel">
<option></option>
<?php
while($row = mysql_fetch_assoc($result)){
echo "<option>{$row['<col>']}</option>";
}
?>
</select>
精彩评论