Ver Mensaje Individual
  #5 (permalink)  
Antiguo 09/11/2012, 17:58
Avatar de Gerardo12
Gerardo12
 
Fecha de Ingreso: octubre-2012
Ubicación: Veracruz,Veracruz
Mensajes: 12
Antigüedad: 11 años, 10 meses
Puntos: 0
Respuesta: Tablas Dinamicas con Selects

hola muchas gracias por responder asta el momento he estado buscando informacion y sigo trabajando con javascript y ya logro conectar la base de datos y obtenerlos tambien pero los datos son almacenados en un json el problema k presento ahora es como mandar a llamar ese json y poder emplearlo. te muestro los codigos son tres archivos pero solo te mostrare dos el de conectar a la base de datos no tengo problemas tengo problemas con lso sigueintes dos.

data.php
Código PHP:
Ver original
  1. <?php
  2.     #Include the connect.php file
  3.     include('connect.php');
  4.     #Connecar con la base de datos
  5.     //connection String
  6.     $connect = mysql_connect($hostname, $username)
  7.     or die('Could not connect: ' . mysql_error());
  8.     //selecciona la base de datos
  9.     $bool = mysql_select_db($database, $connect);
  10.     if ($bool === False){
  11.        print "can't find $database";
  12.     }
  13.    
  14.     $query = "SELECT * FROM recursoshumanos";
  15.     // filter data.
  16.     if (isset($_GET['filterscount'])) {
  17.         $filterscount = $_GET['filterscount'];
  18.        
  19.         if ($filterscount > 0)
  20.         {
  21.             $where = " WHERE (";
  22.             $tmpdatafield = "";
  23.             $tmpfilteroperator = "";
  24.             // build the query.
  25.             $query = "SELECT * FROM recursoshumanos" . $where;     
  26.         }
  27.     }
  28.  
  29.     $result = mysql_query($query) or die("SQL Error 1: " . mysql_error());
  30.     $orders = array();
  31.  
  32.     // get data and store in a json array
  33.     while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  34.         $orders[] = array(
  35.             //'OrderDate' => $row['OrderDate'],
  36.             'clave_rh' => $row['clave_rh'],
  37.             'nombre_rh' => $row['nombre_rh'],
  38.             'apellidos' => $row['apellidos'],
  39.             'sexo' => $row['sexo'],
  40.             'estado_civil' => $row['estado_civil'],
  41.             'fecha_nacimiento' => $row['fecha_nacimiento'],
  42.             'nacionalidad' => $row['nacionalidad'],
  43.             'direccion' => $row['direccion'],
  44.             'codigo_postal' => $row['codigo_postal'],
  45.             'tel_movil' => $row['tel_movil'],
  46.             'tel_fijo' => $row['tel_fijo'],
  47.             'email' => $row['email'],
  48.             'fotografia' => $row['fotografia'],
  49.             'grado_academico' => $row['grado_academico'],
  50.             'institucion_academica' => $row['institucion_academica'],
  51.             'area_conocimiento' => $row['area_conocimiento'],
  52.             'descripcion_area' => $row['descripcion_area'],
  53.             'especialidad' => $row['especialidad'],
  54.             'lengua_extrangera' => $row['lengua_extrangera'],
  55.             'doc_cv' => $row['doc_cv'],
  56.             'categoria' => $row['categoria'],
  57.             'fecha_registro' => $row['fecha_registro']
  58.           );
  59.     }
  60.     $data = json_encode($orders);
  61.    
  62. ?>

el siguiente archivo igualmente es un php



Código PHP:
Ver original
  1. <script type="text/javascript">
  2.    
  3.        
  4.      $(document).ready(function () {
  5.             // prepare the data
  6.             var theme = 'classic';
  7.      
  8.             var source =  {
  9.             //aqui considero yo que deveria mandar a llamar al json
  10.                  datatype: "json",
  11.                  datafields: [
  12.                      { name: 'clave_rh'},
  13.                      { name: 'nombre_rh'},
  14.                      { name: 'apellidos'},
  15.                      { name: 'sexo'},
  16.                      { name: 'estado_civil'},
  17.                      { name: 'fecha_nacimiento'},
  18.                      { name: 'nacionalidad'},
  19.                      { name: 'direccion'},
  20.                      { name: 'codigo_postal'},
  21.                      { name: 'tel_movil'},
  22.                      { name: 'tel_fijo'},
  23.                      { name: 'fotografia'},
  24.                      { name: 'grado_academico'},
  25.                      { name: 'institucion_academica'},
  26.                      { name: 'area_conocimiento'},
  27.                      { name: 'descripcion_area'},
  28.                      { name: 'especialidad'},
  29.                      { name: 'lengua_extrangera'},
  30.                      { name: 'doc_cv'},
  31.                      { name: 'categoria'},
  32.                      { name: 'fecha_registro'}
  33.                 ],
  34.                 url: 'data.php',
  35.                 filter: function()
  36.                 {
  37.                     // actualizar el grid y envia una solicitud al servidor.
  38.                     $("#jqxgrid").jqxGrid('updatebounddata');
  39.                 }
  40.             };     
  41.            
  42.              var dataAdapter = new $.jqx.dataAdapter(source);
  43.            
  44.             // initialize jqxGrid
  45.             $("#jqxgrid").jqxGrid( {       
  46.                 width: 1000,
  47.                 source: dataAdapter,
  48.                 theme: theme,
  49.                 showfilterrow: true,
  50.                 filterable: true,
  51.                 columns: [
  52.                       { text: 'Nº Control',filtertype: 'list', datafield: 'clave_rh', width: 200 },
  53.                       { text: 'Nombre',filtertype: 'list', datafield: 'nombre_rh', width: 200 },
  54.                       { text: 'Apeidos', filtertype: 'list',datafield: 'apellidos', width: 180 },
  55.                       { text: 'Sexo',filtertype: 'list', datafield: 'sexo', width: 100 },
  56.                       { text: 'Estado Civil',filtertype: 'list', datafield: 'estado_civil', width: 140 },
  57.                       { text: 'Fecha de Nacimiento',filtertype: 'list', datafield: 'fecha_nacimiento', width: 200 },
  58.                       { text: 'Nacionalidad', filtertype: 'list',datafield: 'nacionalidad', width: 180 },
  59.                       { text: 'Dirección', filtertype: 'list',datafield: 'direccion', width: 100 },
  60.                       { text: 'Codigo Postal', filtertype: 'list',datafield: 'codigo_postal', width: 140 },
  61.                       { text: 'Telefono Celular', filtertype: 'list',datafield: 'tel_movil', width: 200 },
  62.                       { text: 'Telefono Fijo (Casa)', filtertype: 'list',datafield: 'tel_fijo', width: 180 },
  63.                       { text: 'Fotografia', filtertype: 'list',datafield: 'fotografia', width: 100 },
  64.                       { text: 'Grado Academico', filtertype: 'list',datafield: 'grado_academico', width: 140 },
  65.                       { text: 'Institucion Academica', filtertype: 'list',datafield: 'institucion_academica', width: 200 },
  66.                       { text: 'Area de Conocimiento',filtertype: 'list', datafield: 'area_conocimiento', width: 180 },
  67.                       { text: 'Descripción del Area de Conocimiento', filtertype: 'list',datafield: 'descripcion_area', width: 350 },
  68.                       { text: 'Especialidad', filtertype: 'list',datafield: 'especialidad', width: 140 },
  69.                       { text: 'Idioma Extrangero que maneja',filtertype: 'list', datafield: 'lengua_extrangera', width: 200 },
  70.                       { text: 'Curriculum Vitae', filtertype: 'list',datafield: 'doc_cv', width: 180 },
  71.                       { text: 'Categoria', filtertype: 'list',datafield: 'categoria', width: 100 },
  72.                       { text: 'Fecha de Registro',filtertype: 'list', datafield: 'fecha_registro', width: 140 }
  73.                      
  74.                   ]
  75.             });
  76.         });
  77.     </script>

como puedes empleo algunos otros javascripts pero esos son solo para darle la funcionalidad de filtrado a la tabla, como comente al principio no se esactamente en que apartado podria ingresar el json o no se si exista otra forma de realizarlo.

desde ya muchisimas gracias pro tu respuesta, estoy desesperado por k necesito terminarlo pronto y ya no se k mas hacer por favor ayudame gracias.