Ver Mensaje Individual
  #4 (permalink)  
Antiguo 19/03/2014, 01:51
Avatar de temerariomalaga
temerariomalaga
 
Fecha de Ingreso: marzo-2013
Ubicación: Londres
Mensajes: 156
Antigüedad: 11 años, 1 mes
Puntos: 9
Respuesta: Datatables: Cargar datos en un combobox usando mysql

He intentado cargar los datos como hice con otro archivo, pero ese era un archivo php con un script dentro y si me funcionaba la carga de datos desde la base de datos. Ahora lo he intentado igual pero este archivo es js y parece que no reconoce el php este archivo.
Este es el código php
Código PHP:
Ver original
  1. class Datos{
  2.         function getIdClientes(){
  3.             include"conexion.php";
  4.             mysql_connect($servidor, $usuario, $clave)or die (mysql_errno().mysql_error());
  5.             mysql_select_db($basedatos)or die (mysql_errno().mysql_error());
  6.             result=mysql_query("SELECT id FROM CLIENTES ORDER BY id");
  7.             while($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
  8.                 $id=$row["id"];
  9.             }
  10.             echo $id;
  11.         }
  12.         function getNomClientes(){
  13.             include"conexion.php";
  14.             mysql_connect($servidor, $usuario, $clave)or die (mysql_errno().mysql_error());
  15.             mysql_select_db($basedatos)or die (mysql_errno().mysql_error());
  16.             result=mysql_query("SELECT Nombre FROM CLIENTES ORDER BY id");
  17.             while($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
  18.                 $nombre=$row["Nombre"];
  19.             }
  20.             echo $Nombre;
  21.         }
Y este el archivo js
Código Javascript:
Ver original
  1. <?php
  2.     include"libreria.php";
  3.     $nom=new Datos;
  4.     $cod=new Datos;
  5. ?>
  6.    
  7. (function($){
  8.  
  9. $(document).ready(function() {
  10.     var editor = new $.fn.dataTable.Editor( {
  11.         "ajaxUrl": "php/table.PRESUP.php",
  12.         "domTable": "#PRESUP",
  13.         "fields": [
  14.             {
  15.                 "label": "Serie",
  16.                 "name": "Serie",
  17.                 "type": "text"
  18.             },
  19.             {
  20.                 "label": "Numeroas",
  21.                 "name": "Numeroas",
  22.                 "type": "text"
  23.             },
  24.             {
  25.                 "label": "Codcli",
  26.                 "name": "Codcli",
  27.                 "type": "select",
  28.                 "ipOpts": [
  29.                     {
  30.                         "label": "",
  31.                         "value": ""
  32.                     }
  33.                 ]
  34.             },
  35.             {
  36.                 "label": "Nombre",
  37.                 "name": "Nombre",
  38.                 "type": "text"
  39.             },
  40.             {
  41.                 "label": "Vendedor",
  42.                 "name": "Vendedor",
  43.                 "type": "select",
  44.                 "ipOpts": [
  45.                    
  46.                         {
  47.                             "label": "<?php $nom->getNomClientes();  ?>",
  48.                             "value": "<?php $cod->getIdClientes(); ?>"
  49.                         }
  50.                 ]
  51.             }
  52.         ]
  53.     } );
__________________
Málaga Club de Fútbol: Memoria, Compromiso, Fe