我有一个下拉列表,其中包含MySQL中一个表的源,在该下拉列表中一切都很好显示,但是当我从Google Chrome浏览器中单击查看页面源时,我发现有一个错误
<b>Notice</b>: Undefined variable: buname in <b>.../erac.php</b> on line <b>35</b>"<br />."
我该如何解决?
<label for="label">Business Unit:</label>
<select name="buname" id="buname">
<option value="">Select one</option>
<?php echo load_buname(); ?>
</select>
function load_buname(){
require 'config-mysqli.php';
$sql = "SELECT DISTINCT buname FROM bu";
$result = mysqli_query($connection, $sql);
while($line = mysqli_fetch_array($result)) {
if ($line['buname']==$_POST['buname'])
$selected="selected=\"selected\"";
else
$selected="";
echo "<option value=\"".$line['buname']."\"
$selected>".$line['buname']."</option>";
}
mysqli_close($connection);
}