Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/10/2012, 13:52
Avatar de maximendez88
maximendez88
 
Fecha de Ingreso: septiembre-2012
Ubicación: Montevideo
Mensajes: 131
Antigüedad: 11 años, 7 meses
Puntos: 3
Exclamación mostrar un listado php con ajax

buenas... tengo un listado que hago en php que muestra una tabla de una base de datos sql. Previamente, logre insertar datos en la bd mediante ajax sin refrescar el navegador... El problema esta en que ahora tambien quiero mostrar los datos que voy insertando en la bd... sin refrescar el navegador en una tabla con ajax... espero que alguien me de una mano... dejo mi codigo....


este es mi listado php

Código HTML:
 <?php
include "config.php";


$nombrecir=$_SESSION['namecirc'];

  $query = "SELECT city FROM `sites` WHERE nombreCirc='".$nombrecir."'";
  
  
  
  $result = mysql_query($query);
  $numero = 0;
  while($row = mysql_fetch_array($result))
  {
    echo "<td width=\"25%\"><font face=\"verdana\">" . 
	    $row["city"] . "</font></td>";
    echo "<td width=\"25%\"><font face=\"verdana\">" . 
	    $row["arrival"] . "</font></td>";
    echo "<td width=\"25%\"><font face=\"verdana\">" . 
	    $row["departure"] . "</font></td>";
    echo "<td width=\"25%\"><font face=\"verdana\">" . 
	    $row["comment"]. "</font></td>";    
    $numero++;
  }
  echo "<tr><td colspan=\"15\"><font face=\"verdana\"><b>Número: " . $numero . 
      "</b></font></td></tr>";
  
  mysql_free_result($result);

?> 



y este es el ajax que utlizo previamente para insertar datos en la bd

Código HTML:

	
function objetoAjax(){
 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 save() {
      
       
    
	   

	
	
 ajax=objetoAjax();



 ajax.onreadystatechange=function() {
  if (ajax.readyState==4) {
 

alert("se introdujo con exito en la base de datos");

ajax.open
 
 
 
  }
 }
 
 
 
 var cityvalue=encodeURIComponent(document.getElementById('city').value)
var arrivalvalue=encodeURIComponent(document.getElementById('datepicker_value').value)
var departurevalue=encodeURIComponent(document.getElementById('otrodatepicker_value').value)
var commentvalue=encodeURIComponent(document.getElementById('comment').value)


 
if(arrivalvalue>departurevalue)
{
	alert('Day of arrival can not be after a day of departure');
}


else if(departurevalue<arrivalvalue)
{
	alert('Day of departure can not be until the arrival day');
}

else{
 
  ajax.open("GET", "addCity.php?city="+cityvalue+"&arrival="+arrivalvalue+"&departure="+departurevalue+"&comment="+commentvalue,true);
  
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	
	
//enviando los valores
 ajax.send()
	
	 document.getElementById('savecity').disabled = true;
	    document.getElementById('more').disabled = true; 
	   document.getElementById('ciudad').value = "Select other city";
	   document.getElementById('add').disabled = false;
	   
	   document.getElementById('inner').style.display="block";
	 
	document.getElementById('datepicker_value').value='';
		 document.getElementById('otrodatepicker_value').value='';
		 document.getElementById('comment').value='';


}




 
}

   

Última edición por maximendez88; 09/10/2012 a las 13:57