Ver Mensaje Individual
  #23 (permalink)  
Antiguo 14/01/2014, 02:23
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
Respuesta: Añadir estilo a unas filas.

Gracias Alexis, pero al final lo he hecho así:

Código PHP:
Ver original
  1. while($row = mysql_fetch_array($query))
  2.     {
  3.          
  4.          
  5.          
  6.          
  7.           if($row["facturacion"]=='1' or $row["facturacion"]=='09'){
  8.              
  9.           $style="background-color:red";
  10.              
  11.           }else{
  12.        
  13.          $style="#tr:hover{
  14.         background:#DFEBFF;
  15.        }";
  16.              
  17.           }
  18.    
  19.         $datos[] = array(
  20.             'id_aviso'          => $row['id_aviso'],
  21.             'telefonos'          => $row['telefonos'],
  22.             'name'      => utf8_encode($row['name']),
  23.             'apellidos'       => utf8_encode($row['apellidos']),
  24.             'calle'       => utf8_encode($row['calle']),
  25.             'localidad'        => utf8_encode($row['localidad']),
  26.             'aparatos'        => utf8_encode($row['aparatos']),
  27.             'marcas'        => utf8_encode($row['marcas']),
  28.             'facturacion'        => utf8_encode($row['facturacion']),
  29.             'style'                 => $style
  30.            
  31.            
  32.            
  33.         );
  34.     }



Código Javascript:
Ver original
  1. $.each(data, function(i,item){
  2.  
  3. html_user += '<tr onclick="pulsar1(this, ' + *String.fromCharCode(39) + item.id_aviso + String.fromCharCode(39) *+ ');"     ondblclick="pulsar(this, ' + *String.fromCharCode(39) + item.id_aviso + String.fromCharCode(39) *+ ');" >';
  4. html_user += '<td style="'+item.style+'"><input name="demo" type="checkbox" value="' + item.id_aviso + '"/></td>';
  5.  html_user += '<td  style="'+item.style+'">'+item.id_aviso+'</td>';
  6.  html_user += '<td  style="'+item.style+'">'+item.telefonos+'</td>';
  7.  html_user += '<td  style="'+item.style+'">'+item.name+' '+item.apellidos+'</td>';
  8.  html_user += '<td  style="'+item.style+'">'+item.calle+'</td>';
  9.  html_user += '<td  style="'+item.style+'">'+item.localidad+'</td>';
  10.  html_user += '<td  style="'+item.style+'">'+item.aparatos+'</td>';
  11.  html_user += '<td  style="'+item.style+'">'+item.marcas+'</td>';
  12.  html_user += '<td  style="'+item.style+'">'+item.facturacion+'</td>';
  13. html_user += '</tr>';
  14.  
  15.  
  16.  });


Como lo ves, se puede mejorar ?


Una pregunta:

Cuando ingreso el valor "1" o "09" del campo facturacion en la base de datos me lo ingresa dejando espacios después de dichos valores. Y al sacar el array me lo imprime así:

[{"facturacion":"1 (aquí es donde van los espacios en blanco) "}]

Y claro cuando quiero buscar el valor "1" me dice que no se encuentra. Entonces tengo que entrar en la base de datos y eliminar esos espacios.

Porque puede ser ?

Última edición por satjaen; 14/01/2014 a las 03:12