0

I have this function which used to work, but apparently decided to take a dump on me. Does anybody have any idea of what could be wrong?

<?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>

The php that is called goes something like this:

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'];
   }
}

I've tried everything but I really can't pinpoint the problem!

9
  • 1
    php, html, and javascript in one file?! Commented Apr 27, 2012 at 12:28
  • 1
    #estafil is a <select> element: are you appending <option> element? what's the content of ajax response? what if you change echo $row['Nombre']; with echo "<option>".$row['Nombre']."</option>"; Commented Apr 27, 2012 at 12:32
  • @ScottM. I believe they call it tag soup :) en.wikipedia.org/wiki/Tag_soup Commented Apr 27, 2012 at 12:32
  • tag soup, sounds refreshing to me :) Commented Apr 27, 2012 at 12:36
  • @ScottM. Thats just for explanation purposes. Commented Apr 27, 2012 at 12:37

1 Answer 1

2

You are returning a text. Please try this code

   while($row = mysql_fetch_assoc($extract)){
        echo '<option>'.$row['Nombre'].'</option>';
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.