Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/04/2007, 21:46
mauricioo0
 
Fecha de Ingreso: agosto-2005
Mensajes: 2
Antigüedad: 18 años, 9 meses
Puntos: 0
Re: Guardar variable

Ya lo he resuelto ")... pongo la solucion ..

Ejemplo.php

Código PHP:
<html>
<
head>
<
title>AjaxEjemplo 2 Envío de datos por el método GET</title>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</
head>
<
script language="javascript">
function 
nuevoAjax(){
var 
xmlhttp=false;
 try {
  
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (
e) {
  try {
   
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (
E) {
   
xmlhttp false;
  }
 }

if (!
xmlhttp && typeof XMLHttpRequest!='undefined') {
  
xmlhttp = new XMLHttpRequest();
}
return 
xmlhttp;
}
function 
cargarContenido(){
var 
t1contenido;
contenido document.getElementById('contenido');
t1 document.getElementById('texto1').value;
ajax=nuevoAjax();
ajax.open("GET""basededatos2.php?t1="+t1,true);
ajax.onreadystatechange=function() {
if (
ajax.readyState==4) {
contenido.innerHTML ajax.responseText
}
}
ajax.send(null)
}

</script>
<style type="text/css">
#contenedor{
border: 1px solid #f00;
padding: 10px;
margin: 14px;
}
</style>
<body>
<form onSubmit="cargarContenido(); return false">
<div><input type="text" id="texto1" value="valor1" /></div>
<div><input type="submit" value="Buscar" onPress="cargarContenido()" /></div>
</form>

<div id="contenido"></div>

</body>
</html> 
Y el q jalamos
basededatos2.php
Código PHP:
<?

include("servidor.php");//Abrimos conexion
$fnom=$_GET['t1'];
$conexion=mysql_connect(HOST,USUARIO,PASS) or die ("Hay un error en la conexion de la base de datos(host, name o pass)");

//Seleccionamos BD
$bd =mysql_select_db(BASE,$conexion) or die ("No existe base de datos");

//Hacemos consulta
$consulta"SELECT * FROM proyecto WHERE nombre='$fnom'";
$resultado=mysql_query($consulta) or die ("No hay tablas");

//echo mysql_num_rows($resultado);

echo "<table border='1' >";
while(
$fila =mysql_fetch_array($resultado,MYSQL_ASSOC)){
    
extract($fila);
    echo 
"<tr><td>".$id_proyecto."</td>";
    echo 
"<td>".$NOMBRE."</td>";
    echo 
"<td>".$APELLIDOS."</td>";
    echo 
"<td>".$EDAD."</td></tr>";
}
echo
"</table>";

//Cerramos conexion
mysql_close($conexion);
?>