Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/09/2016, 05:37
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 8 meses
Puntos: 10
Numerar los registros totales

Hola por favor tengo este código que me funciona bien pero quisiera añadirle al final de la lista o datos recuperados un mensaje diciendo cuantos registros se han encontrado.


Código PHP:
Ver original
  1. <?php
  2. include("Connections/wedserver2012.php");
  3. if ($_GET["action"] == "listar")
  4. {
  5.     // valores recibidos por POST
  6.  
  7.     $emis= $_POST['emision'];
  8.  
  9.  
  10.  
  11. if ( ! empty($emis)) {
  12.      
  13. $sql ="(SELECT 1 as qnum,id_aviso,telefonos,telefonos3,movil,dni,name,apellidos,localidad,calle,aparatos,marcas,modelo,codigo,serie,facturacion
  14.  
  15. FROM avisos WHERE emision='$emis' order by id_aviso )";
  16.  
  17.  
  18. }  
  19.  
  20.  
  21.  
  22.     // Ordenar por
  23.     $vorder = $_POST['orderby'];
  24.    
  25.     if($vorder != ''){
  26.         $sql .= " ORDER BY ".$vorder;
  27.     }
  28.      
  29.  
  30.      
  31.     $query = mysql_query($sql);
  32.     if (!$sql) {
  33.     die('Consulta no válida: ' . mysql_error());
  34. }
  35.     if (mysql_num_rows($query)>0 ) {
  36.        
  37.  
  38.          
  39.   $datos = array();
  40.      
  41. while($row = mysql_fetch_array($query)) {
  42.          
  43.  
  44.    
  45.         $datos[] = array(
  46.    
  47.        
  48.              'id_aviso'          => $row['id_aviso'],
  49.             'telefonos'          => $row['telefonos'],
  50.             'name'      => utf8_encode($row['name']),
  51.             'apellidos'       => utf8_encode($row['apellidos']),
  52.             'calle'       => utf8_encode($row['calle']),
  53.             'localidad'        => utf8_encode($row['localidad']),
  54.             'aparatos'        => utf8_encode($row['aparatos']),
  55.             'marcas'        => utf8_encode($row['marcas']),
  56.              'modelo'        => utf8_encode($row['modelo']),
  57.               'codigo'        => utf8_encode($row['codigo']),
  58.                'serie'        => utf8_encode($row['serie']),
  59.             'facturacion'        => utf8_encode($row['facturacion']),
  60.             'style'                 => $style
  61.            
  62.            
  63.            
  64.         );
  65.    
  66.     }
  67.     // convertimos el array de datos a formato json
  68.     echo json_encode($datos);
  69. /* Tienes resultados. */
  70.     }else{
  71. /*No tienes resultados. */
  72.     echo '[]';
  73.         }
  74.   }
  75. ?>





Código PHP:
Ver original
  1. function filtrar(){
  2.  
  3. $.ajax({
  4. data: $("#frm_filtro").serialize()+ordenar,
  5. type: "POST",
  6. dataType: "json",
  7. url: "ajax.php?action=listar",
  8. beforeSend:function(){
  9. $('.loader').css({display:'block'});
  10.   },
  11.  complete: function() {
  12.          $('.loader').css({display:'none'});
  13. },
  14.  success: function(data){
  15.  var html_user ='' ;
  16.  if(data.length > 0){
  17. $.each(data, function(i,item){
  18.  
  19.  
  20.  
  21. html_user += '<tr id="fila1">';
  22. html_user += '<td style="'+item.style+'"><input  onClick="marcar(this)" name="demo" type="checkbox" value="' + item.id_aviso + '"/></td>';
  23. html_user += '<td  style="'+item.style+'">'+item.id_aviso+'</td>';
  24. html_user += '<td  style="'+item.style+'">'+item.telefonos+'</td>';
  25. html_user += '<td  style="'+item.style+'">'+item.name+' '+item.apellidos+'</td>';
  26. html_user += '<td  style="'+item.style+'">'+item.calle+'</td>';
  27. html_user += '<td  style="'+item.style+'">'+item.localidad+'</td>';
  28. html_user += '<td  style="'+item.style+'">'+item.aparatos+'</td>';
  29. html_user += '<td  style="'+item.style+'">'+item.marcas+'</td>';
  30. html_user += '<td  style="'+item.style+'">'+item.modelo+'</td>';
  31. html_user += '<td  style="'+item.style+'">'+item.codigo+'</td>';
  32. html_user += '<td  style="'+item.style+'">'+item.serie+'</td>';
  33. html_user += '<td  style="'+item.style+'">'+item.facturacion+'</td>';
  34. html_user += '</tr>';
  35.  
  36.  
  37. });
  38. }

Última edición por satjaen; 27/09/2016 a las 05:42