0

我有这个曾经可以工作的功能,但显然决定对我进行转储。有人知道可能出了什么问题吗?

<?php 
require("php/connect.php");
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Clasificados</title> 
<link rel="stylesheet" href="css/index.css"/>
<link type="text/css" href="css/excite-bike/jquery-ui-1.8.19.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.19.custom.min.js"></script>
<script type="text/javascript">

$(function() {
    $.post(
        'php/bridge.php', 
        {
            fun:"estados"
        },
        function(answer){
            if(answer){
                $('#estafil').append(answer);
            }
        }
    );

});


</script>
</head>
<body>
<div id="left">
<form name="search">
    <fieldset>
        <label for="searchbar">Introduce terminos de busqueda:</label>
        <input type="text" name="searchbar" id="searchbar" class="text ui-widget-content ui-corner-all" />
        <label for="estafil">Filtrar por estados:</label>
        <select name="estafil" id="estafil" class="text ui-widget-content ui-corner-all" >
        </select>
        <input type="submit" value="Inciciar busqueda" />
    </fieldset>
</form>
</div>
</body>

被调用的 php 是这样的:

require("connect.php");
session_start();
$fun=$_POST['fun'];
$rol=$_SESSION['rol'];
$id=$_SESSION['id'];
if($fun=="estados"){
   $query="SELECT Nombre FROM estados";
   $extract=mysql_query($query) or die(mysql_error());
   while($row = mysql_fetch_assoc($extract)){
       echo $row['Nombre'];
   }
}

我已经尝试了一切,但我真的无法确定问题所在!

4

1 回答 1

2

您正在返回一个文本。请尝试此代码

   while($row = mysql_fetch_assoc($extract)){
        echo '<option>'.$row['Nombre'].'</option>';
    }
于 2012-04-27T12:33:20.310 回答