no he podido encontrar el error en mi codigo
espero alguien pueda ayudarme
se selecciona una opcion de una lista desplegable y aparecen los albums de la banda
el archivo PHP ya lo probe y si funciona el problema esta en el script, pero no de especificamente en donde.. gracias de antemano...
<html>
<head>
<script type="text/javascript">
function showAlbum(str)
{
var xmlhttp;
document.getElementById("datos_consulta").innerHTML=str;
if (str=="")
{
document.getElementById("datos_consulta").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
alert ("objeto creadoo...!!!")
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
var string= "serverAjaxConsultar.php?banda_id=" + str;
xmlhttp.open('get', string, true);
xmlhttp.onreadystatechange = queryReply;
xmlhttp.send(null);
alert(string);
}
function queryReply() {
if(xmlhttp.readyState == 4){
var response = xmlhttp.responseText;
document.getElementById('datos_consulta').innerHTML = 'Datos: '+response;
}
}
</script>
</head>
<body>
<form action="">
<select name="bandas" onchange="showAlbum(this.value)">
<option>Selecciona banda</option>
<?php
mysql_connect('localhost','root','qw');
mysql_select_db('nickel');
$query="select id, nombre from t_bandas order by nombre";
$result=mysql_query($query);
while(list($id, $nombre)=mysql_fetch_row($result)) {
echo "<option value=".$id.">".$nombre."</option>";
}
?>
</select>
</form>
<br />
<div id="datos_consulta"> Datos del album</div>
</body>
</html>
---------------------
anexo PHP de todos modos
<html>
<body>
<?php
$coneccion= mysql_connect("localhost","root","qw")
or die("no pudo conectarse al servidor");
mysql_select_db("nickel",$coneccion)
or die("no se pudo conectar");
$comandoSQL= "select nombre, enlace from t_albums where id_banda=".$_GET['banda_id'].";";
$consulta= mysql_query($comandoSQL,$coneccion)
or die("no se pudo hacer la consulta");
$cantidad_columnas = mysql_num_fields($consulta);
echo "<table border='1'>";
while ( $fila= mysql_fetch_array($consulta) )
{
printf( "<tr>\n" );
for($i=0; $i<$cantidad_columnas ; $i= $i+1 )
{
printf( "<td> %s </td>\n", $fila[ $i ] );
}
printf( "</tr>\n" );
}
echo "</table>";
mysql_close($coneccion);
?>
</body>
</html>
graciaaas..