Foros del Web » Programando para Internet » PHP »

Problema con envío de variables en PHP por URL

Estas en el tema de Problema con envío de variables en PHP por URL en el foro de PHP en Foros del Web. Hola, Necesito ayuda Estoy desarrollando un sitio con PHP para la consulta derivada de datos a MySQL para la gestión de datos Telefónicos. El reto ...
  #1 (permalink)  
Antiguo 01/11/2011, 10:47
 
Fecha de Ingreso: noviembre-2011
Mensajes: 3
Antigüedad: 12 años, 5 meses
Puntos: 0
Problema con envío de variables en PHP por URL

Hola,

Necesito ayuda

Estoy desarrollando un sitio con PHP para la consulta derivada de datos a MySQL para la gestión de datos Telefónicos.

El reto es el siguiente:

Al prinicipio mi site generará una consulta general por default, a continuación en la etapa 1 el usuario podrá especificar el reporte a desplegar seleccionando el Mes, Año y Área (por medio de listas desplegables, resultantes de una consulta a MySql) requeridos para su reporte; a continuación se generará el reporte en tablas por Concepto (lada, llamadas locales, etc), Minutos e importe además de los totales de Minutos e Importe.

Hasta aquí ya desarrollé sin problemas la primera etapa del site.

El problema viene en la 2da pantalla que genera el reporte donde los Conceptos serán links que al darles click generarán un reporte consecuente donde desplegaré el detalle que contendrá todos los números telefónicos, minutos e importes de llamadas del mismo concepto; es decir, si doy click en "Lada Nacional" me desplegará todos los teléfonos con sus respectivos minutos (duración de llamadas) e importes generados del mismo concepto (lada, local, etc) y del mismo año, mes y área seleccionado.

El problema es el siguiente:
Por ser una consulta especifica derivada de la consulta anterior, no puedo refrescar la página, por lo tanto use el envío de variables por URL utilizando HASH (#) y javascript. Para el envío de variables lo hago utilizando AJAX y métodos lanzados por el evento onClick (en los links) y onChange (en las listas desplegables).

Las variables de año, mes y área no tienen ningún problema en su tráfico a HTML (local) y PHP (servidor) y viceversa; pero al mandar la información del link seleccionado, esta variable a veces se atrasa; es decir, me manda la seleccionada anteriormente por el usuario y no la actual.

Ese es el conflicto de variables que tengo, además de que no respeta onclick, es decir, tengo que dar doble click para que pase la variable del link seleccionado, si doy un solo click me genera conflicto o me manda la variable anterior.

Espero me puedan ayudar y si hay alguna duda podré ser más específico.

Gracias de antemano.
  #2 (permalink)  
Antiguo 01/11/2011, 10:48
 
Fecha de Ingreso: noviembre-2011
Mensajes: 3
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: Problema con envío de variables en PHP por URL

Clase ControlTelefónico.php :

Código:
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//ES" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta name="keywords" content="" />
  4. <meta name="description" content="" />
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6.  
  7.  
  8.  
  9. <script language="JavaScript" type="text/JavaScript" src="Recursos/plantilla.js">                           </script>
  10. <link href="Recursos/plantilla.css" rel="stylesheet" type="text/css">
  11. <link rel="shortcut icon" href="Recursos/telmex_ico.ico">
  12. <script src="mootools-core-1.3.2-full-compat-yc.js" type="text/javascript"></script>
  13. <script language="javascript">
  14.  
  15. timer=setTimeout("verseleccion();verseleccion_concepto()",0);;
  16.  
  17. function verseleccion()
  18.        
  19. {
  20.  
  21. window.addEvent('domready', function(){
  22.             var valor_mes="";
  23.             var valor_annio="";
  24.             var valor_sub="";
  25.             var valor="";
  26.  
  27.             var sub=document.getElementById("cb_subdireccion");
  28.             var valor_sub=sub.value;
  29.  
  30.             var mes=document.getElementById("cb_mes");
  31.             var valor_mes=mes.value;
  32.  
  33.             var annio=document.getElementById("cb_anio");
  34.             var valor_annio=annio.value;
  35.            
  36.             var valor="";
  37.            
  38.            
  39.  
  40.  
  41. var mis_datos = [
  42.         [      
  43.             valor_mes,
  44.            
  45.         ],
  46.         [
  47.             valor_annio,
  48.            
  49.         ],
  50.         [
  51.             valor_sub,
  52.            
  53.         ],
  54.         [
  55.            
  56.             valor,
  57.         ],
  58.        
  59. ];
  60.  
  61.         //convierto ese array en un JSON con Mootools
  62.         var miJSON = JSON.encode(mis_datos);
  63.        
  64.         //pondríamos esto para ver el JSON generado en la capa con id=resultado
  65.         //$('resultado').set("html", "<pre>" + miJSON + "</pre>");
  66.        
  67.         //creo una conexión
  68.         var miAjax = new Request({
  69.             url: "recibo-json.php",
  70.             data: "datos=" + miJSON,
  71.             onSuccess: function(textoRespuesta){
  72.                 $('resultado').set("html", textoRespuesta);
  73.             },
  74.             onFailure: function(){
  75.                 $('resultado').set("html", "fallo en la conexión Ajax");
  76.             }
  77.         })
  78.         miAjax.send();
  79.     });
  80.  
  81.  
  82.  
  83.        
  84.         }
  85.  
  86. function verseleccion_concepto()
  87.         {
  88.  
  89.  
  90. window.addEvent('domready', function(){
  91.             var valor_mes="";
  92.             var valor_annio="";
  93.             var valor_sub="";
  94.             var valor="";
  95.  
  96.             var sub=document.getElementById("cb_subdireccion");
  97.             var valor_sub=sub.value;
  98.  
  99.             var mes=document.getElementById("cb_mes");
  100.             var valor_mes=mes.value;
  101.  
  102.             var annio=document.getElementById("cb_anio");
  103.             var valor_annio=annio.value;
  104.            
  105.             var valor=window.location.hash;
  106.            
  107.            
  108.  
  109.  
  110.  
  111. var mis_datos = [
  112.         [      
  113.             valor_mes,
  114.            
  115.         ],
  116.         [
  117.             valor_annio,
  118.            
  119.         ],
  120.         [
  121.             valor_sub,
  122.            
  123.         ],
  124.         [
  125.             valor,
  126.            
  127.         ],
  128. ];
  129.  
  130.         //convierto ese array en un JSON con Mootools
  131.         var miJSON = JSON.encode(mis_datos);
  132.        
  133.         //pondríamos esto para ver el JSON generado en la capa con id=resultado
  134.         //$('resultado').set("html", "<pre>" + miJSON + "</pre>");
  135.        
  136.         //creo una conexión
  137.         var miAjax = new Request({
  138.             url: "recibo-json.php",
  139.             data: "datos=" + miJSON,
  140.             onSuccess: function(textoRespuesta){
  141.                 $('resultado').set("html", textoRespuesta);
  142.             },
  143.             onFailure: function(){
  144.                 $('resultado').set("html", "fallo en la conexión Ajax");
  145.             }
  146.         })
  147.         miAjax.send();
  148.     });
  149.  
  150.  
  151.  
  152.        
  153.         }
  154.  
  155.  
  156.    
  157.     </script>
  158.  
  159.  
  160. <title>TELMEX - Control Telef&oacutenico</title>
  161.    
  162.  
  163. <?php
  164.  
  165.    
  166.     header("Content-Type: text/html;charset=utf-8");//para manejar acéntos
  167.         session_start();
  168.     include_once 'Conexion.php';
  169.    
  170.         if($_SESSION['usuario'])
  171.      {
  172.         $usuario=$_SESSION['usuario'];
  173.  
  174.         include_once 'Conexion.php';
  175.         $consulta="SELECT nombre_usuario, a_paterno, a_materno FROM usuario WHERE usuario='".$usuario."'";
  176.         mysql_query("SET NAMES 'utf8'");
  177.        
  178.         $res=mysql_query($consulta);
  179.        
  180.         mysql_connect("localhost","control_tel","admin");
  181.         mysql_select_db("control_telefonico");
  182.        
  183.         while ($row = mysql_fetch_row($res))
  184.         {
  185. ?>
  186.  
  187. </head>
  188.  
  189. <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload=tiempo()>
  190.  
  191.  
  192. <table width="100%" height="80%" border="0">
  193. <tr>
  194.     <td height="10"><table width="100%" border="0" cellspacing="0" cellpadding="0" VALIGN="top">
  195.      
  196.       <tr>
  197.         <td width="100%" height="46" valign="bottom">
  198.        
  199.        <h1><font color="#2E73C8">&nbsp;Control Telef&oacutenico</font></h1></td>
  200.        
  201.        <td width="10%"><center><img align= "center" src="Recursos/logo_telmex.jpg" width="226" height="45"></center></td>
  202.      </tr>
  203.      <tr>
  204.        <td colspan="2" bgColor="#2E73C8" height="25" valign="bottom">
  205.  
  206. <h2><font color="#F7F8E0"> &nbsp;
  207.        
  208.        
  209. <?php
  210.          
  211. $fecha =time();
  212.  
  213.     if(date("a")=="am")
  214.     {
  215.     echo "Buenos d&iacuteas";
  216.     }
  217.     else
  218.     {
  219.     echo "Buenas tardes";
  220.     }
  221.  
  222.     header("Content-Type: text/html;charset=utf-8");
  223.  
  224.     echo " ";
  225.     echo "$row[0]";
  226.     echo " ";
  227.     echo "$row[1]";
  228.     echo " ";
  229.     echo "$row[2]";
  230.     }
  231.    
  232. }
  233.  
  234. else
  235. {
  236. echo 'No has iniciado sesion';
  237. }
  238. ?>
  239.  
  240.         </font></h2>
  241.  
  242.     </td>
  243.       </tr>
  244.     </table></td>
  245.   </tr>
  246.   <tr>
  247.     <td height="22" valign="top">
  248.     <center>
  249.  
  250.     <h2><font>Generar Reporte: </font></h2>
  251.     </center></td>
  252.    
  253.   </tr>
  254.   <tr>
  255.    <td height="30">
  256.     <table width="100%" height="100%">
  257.     <tr>
  258.     <td width="38%" height="49">
  259.     <center>
  260.    
  261.     <strong>Por mes:</strong>
  262.  
  263.    
  264.        <?php
  265.         $SQL="SELECT DISTINCT mes_text FROM cuenta order by mes DESC";
  266.         $result=mysql_query($SQL);
  267.  
  268.         echo '<select name="cb_mes" id="cb_mes" size=1 style="width:120px" onchange="verseleccion(); verseleccion_concepto()">';
  269.        
  270.         // DESPLIEGA
  271.         while ($row=mysql_fetch_array($result))
  272.         {
  273.             echo '<option value="'.$row["mes_text"].'">'.$row["mes_text"];
  274.         }
  275.         //mysql_free_result($result);
  276.         echo '</select>';
  277.  
  278.     ?>
  279.  
  280.    
  281.     <strong>&nbsp; A&ntildeo:</strong>
  282.  
  283.    
  284.     <?php
  285.          
  286.         $SSQL="SELECT DISTINCT anio FROM cuenta order by anio";
  287.         $resultado=mysql_query($SSQL);
  288.  
  289.         echo '<select name="cb_anio" id="cb_anio" size=1 style="width:80px" onchange="verseleccion(); verseleccion_concepto()">';
  290.        
  291.         // DESPLIEGA
  292.         while ($row=mysql_fetch_array($resultado))
  293.         {
  294.             echo '<option value="'.$row["anio"].'">'.$row["anio"];
  295.         }
  296.         //mysql_free_result($resultado);
  297.         echo '</select>';
  298.        ?>
  299.     </center>
  300.     </td>
  301.     <td width="62%">
  302. <form name="subdireccion" method="post">
  303.     <strong>Subdirecci&oacuten de Sistemas:&nbsp; </strong>
  304.  
  305.  
  306.        
  307.        <?php
  308.         $SQL="SELECT DISTINCT area FROM cuenta order by area DESC";
  309.         $result=mysql_query($SQL);
  310.  
  311.         echo '<select name="cb_subdireccion" id="cb_subdireccion" size=1 style="width:430px" onchange="verseleccion(); verseleccion_concepto()">';
  312.         echo '<<option value="TODOS">TODOS</option>';
  313.         // DESPLIEGA
  314.         while ($row=mysql_fetch_array($result))
  315.         {
  316.             echo '<option value="'.$row["area"].'">'.$row["area"];
  317.         }
  318.         //mysql_free_result($result);
  319.         echo '</select>';
  320.  
  321.     ?>
  322.        
  323.        
  324.     </center>
  325.     </td>
  326.     </tr>
  327.     <tr>
  328.      <td colspan="2" bgColor="#2E73C8" height="5" valign="bottom">
  329.      </td>
  330.     </tr>
  331.    
  332.     </table>
  333.     </td>
  334.    
  335.   </tr>
  336.  
  337.   <tr>
  338.    <td valign="top"><center>
  339.     <strong> <h2> R E S U M E N </h2> </strong> </center>
  340.  
  341.  
  342.  
  343.  
  344. <div id=resultado> </div>
  345.  
  346.  
  347. <?php
  348.  
  349. function dameURL()
  350. {
  351. $url="http://".$_SERVER['HTTP_HOST'].":".$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'];
  352. return $url;
  353. }
  354. echo 'Valor URL: ';
  355. echo dameURL();
  356.  
  357. ?>
  358.  
  359.  
  360.  
  361. </body>
  362. </html>
  #3 (permalink)  
Antiguo 01/11/2011, 10:49
 
Fecha de Ingreso: noviembre-2011
Mensajes: 3
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: Problema con envío de variables en PHP por URL

Clase recibo-json.php DONDE PROCESO MIS VARIABLES Y LAS MANDO DE REGRESO AL HTML en ControlTelefonico.php

Código PHP:
Ver original
  1. [PHP]
  2. <?php
  3.  
  4. echo "<META HTTP-EQUIV='refresh' CONTENT='0; URL=recivo-json.php'>";
  5. echo strpos($_SERVER['PHP_SELF'], '?') !== false ? substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], '?')) : $_SERVER['PHP_SELF'];
  6.  
  7. if($_POST){
  8.  
  9.  
  10. //echo "recibo algo POST";
  11.  
  12. //recibo los datos y los decodifico con PHP
  13. $misDatosJSON = json_decode($_POST["datos"]);
  14.  
  15. //con esto podría mostrar todos los dtos del JSON recibido
  16. //print_r($misDatosJSON);
  17.  
  18. //ahora muestro algún dato de este array bidimiesional
  19.  
  20. $mes ="";
  21. $annio= "";
  22. $subdireccion= "";
  23. $concepto= "";
  24.  
  25. $mes =$misDatosJSON[0][0];
  26. $annio= $misDatosJSON[1][0];
  27. $subdireccion= $misDatosJSON[2][0];
  28. $concepto=$misDatosJSON[3][0];
  29.  
  30. //echo utf8_encode($salida);
  31. echo $mes;
  32. echo '<br>';
  33. echo $annio;
  34. echo '<br>';
  35. echo $subdireccion;
  36. echo '<br>';
  37.  
  38. echo '<br>';
  39. $concepto_bien="";
  40. $concepto_bien= substr($concepto,1);
  41. echo $concepto_bien;
  42.  
  43.  
  44.  
  45.  
  46. if($concepto=="")
  47. //abre A
  48. {
  49. //abre a1
  50. if($subdireccion=="TODOS")
  51. {
  52.  
  53. include_once 'Conexion.php';
  54. $sql="select concepto.concepto,sum(duracion),sum(importe) from cuenta,concepto where mes_text = '".$mes."' and anio = '".$annio."' and concepto.cve_cargo = cuenta.cve_cargo group by concepto.concepto order by sum(importe) DESC";
  55. $result= mysql_query($sql) or die(mysql_error());
  56. if(mysql_num_rows($result)==0) die("No hay registros para mostrar");
  57. /* Desplegamos cada uno de los registros dentro de una tabla */
  58.  
  59. echo '<center><table border=1 cellpadding=4 cellspacing=0>';
  60.  
  61. /*Priemro los encabezados*/
  62. echo '
  63. <th bgColor="69a9f7" width="300px"> Concepto </th>
  64. <th bgColor="69a9f7" width="150px" > Minutos </th>
  65. <th bgColor="69a9f7" width="150px"> Importe </th>
  66.  
  67. </tr>';
  68.  
  69. /*Y ahora todos los registros */
  70.  
  71.  
  72. $duracion_suma=0;
  73. $importe_suma=0;
  74.  
  75. while($row=mysql_fetch_array($result))
  76. {
  77.  
  78. $temp=utf8_encode($row["concepto"]);
  79. echo '<tr><td> <div align=left> <a onClick="verseleccion_concepto();verseleccion_conc epto();actualiza()" href="http://srvsiatel12/ControlTelefonico/ControlTelefonico.php#';
  80. echo $temp;
  81. echo utf8_encode('" value="'.$row["concepto"].'" id="'.$row["concepto"].'"> '.$row["concepto"].'</a></div></td>');
  82.  
  83. $duracion=$row["sum(duracion)"];
  84. $duracion_suma=$duracion_suma+ $duracion;
  85. echo '<td> <div align=right>';
  86. echo number_format($duracion,0);
  87. echo '<div></td>';
  88.  
  89. $importe=$row["sum(importe)" ];
  90. $importe_suma= $importe_suma+ $importe;
  91. echo '<td><div><span style="float:right">';
  92. echo number_format($importe,2);
  93. echo '</span>$</div></td>';
  94. }
  95.  
  96. echo '
  97.  
  98. <tr>
  99. <td bgColor="69a9f7"> <div align=right> <strong> Total</strong> </div></td>
  100. <td bgColor="69a9f7">
  101.  
  102. <div align=right> <strong> ';
  103. echo number_format($duracion_suma,0);
  104. echo '</strong></div>';
  105.  
  106. echo '
  107.  
  108. </td>
  109. <td bgColor="69a9f7">
  110. <div><strong><span style="float:right">';
  111. echo number_format($importe_suma,2);
  112. echo '</span>$</strong></div>';
  113.  
  114. echo '</td>
  115. <tr>
  116. <br>
  117. </center>
  118. </table>';
  119. }
  120. //cierra a1
  121.  
  122. //abre a2
  123. else
  124. {
  125.  
  126. include_once 'Conexion.php';
  127. $sql="select concepto.concepto,sum(duracion),sum(importe) from cuenta,concepto where mes_text = '".$mes."' and anio = '".$annio."'and area = '".$subdireccion."' and concepto.cve_cargo = cuenta.cve_cargo group by concepto.concepto order by sum(importe) DESC";
  128.  
  129. $result= mysql_query($sql) or die(mysql_error());
  130. if(mysql_num_rows($result)==0) die("No hay registros para mostrar");
  131.  
  132. echo '<center><table border=1 cellpadding=4 cellspacing=0>';
  133.  
  134. /*Priemro los encabezados*/
  135. echo '
  136. <th bgColor="69a9f7" width="300px"> Concepto </th>
  137. <th bgColor="69a9f7" width="150px" > Minutos </th>
  138. <th bgColor="69a9f7" width="150px"> Importe </th>
  139.  
  140. </tr>';
  141.  
  142. /*Y ahora todos los registros */
  143.  
  144.  
  145. $duracion_suma=0;
  146. $importe_suma=0;
  147.  
  148. while($row=mysql_fetch_array($result))
  149. {
  150. $temp=utf8_encode($row["concepto"]);
  151. echo '<tr><td> <div align=left> <a onClick="verseleccion_concepto();verseleccion_conc epto();actualiza()" href="#';
  152. echo $temp;
  153. echo utf8_encode('" value="'.$row["concepto"].'" id="'.$row["concepto"].'"> '.$row["concepto"].'</a></div></td>');
  154.  
  155. $duracion=$row["sum(duracion)"];
  156. $duracion_suma=$duracion_suma+ $duracion;
  157. echo '<td> <div align=right>';
  158. echo number_format($duracion,0);
  159. echo '<div></td>';
  160.  
  161. $importe=$row["sum(importe)" ];
  162. $importe_suma= $importe_suma+ $importe;
  163. echo '<td><div><span style="float:right">';
  164. echo number_format($importe,2);
  165. echo '</span>$</div></td>';
  166. }
  167.  
  168. echo '
  169.  
  170. <tr>
  171. <td bgColor="69a9f7"> <div align=right> <strong> Total</strong> </div></td>
  172. <td bgColor="69a9f7">
  173.  
  174. <div align=right> <strong> ';
  175. echo number_format($duracion_suma,0);
  176. echo '</strong></div>';
  177.  
  178. echo '
  179.  
  180. </td>
  181. <td bgColor="69a9f7">
  182. <div><strong><span style="float:right">';
  183. echo number_format($importe_suma,2);
  184. echo '</span>$</strong></div>';
  185.  
  186. echo '</td>
  187. <tr>
  188. <br>
  189. </center>
  190. </table>';
  191. }
  192. //cierra a2
  193. }
  194. //cierra A
  195.  
  196.  
  197.  
  198. else
  199. //abre B
  200. {
  201.  
  202. $mes ="";
  203. $annio= "";
  204. $subdireccion= "";
  205. $concepto= "";
  206.  
  207. $mes =$misDatosJSON[0][0];
  208. $annio= $misDatosJSON[1][0];
  209. $subdireccion= $misDatosJSON[2][0];
  210. $concepto=$misDatosJSON[3][0];
  211. $concepto_bien="";
  212. $concepto_bien= substr($concepto,1);
  213.  
  214. echo'<center><strong><h2>';
  215. echo $concepto_bien;
  216. echo'</center></strong></h2>';
  217.  
  218. // abre b1
  219. if($subdireccion=="TODOS")
  220. {
  221. include_once 'Conexion.php';
  222. $sql="select telefono,sum(duracion),sum(importe) from cuenta,concepto where mes_text = '".$mes."' and anio = '".$annio."' and concepto.concepto = '".$concepto_bien."' and concepto.cve_cargo = cuenta.cve_cargo group by telefono order by sum(importe) DESC";
  223.  
  224. $result= mysql_query($sql) or die(mysql_error());
  225. if(mysql_num_rows($result)==0) die("No hay registros para mostrar");
  226.  
  227. echo '<center><table border=1 cellpadding=4 cellspacing=0>';
  228.  
  229. /*Priemro los encabezados*/
  230. echo '
  231. <th bgColor="69a9f7" width="300px"> Concepto </th>
  232. <th bgColor="69a9f7" width="150px" > Minutos </th>
  233. <th bgColor="69a9f7" width="150px"> Importe </th>
  234.  
  235. </tr>';
  236.  
  237. /*Y ahora todos los registros */
  238.  
  239.  
  240. $duracion_suma=0;
  241. $importe_suma=0;
  242.  
  243. while($row=mysql_fetch_array($result))
  244. {
  245.  
  246. $temp=utf8_encode($row["telefono"]);
  247. echo '<tr><td> <div align=left> <a onClick="verseleccion_concepto();verseleccion_conc epto();actualiza()" href="#';
  248. echo $temp;
  249. echo utf8_encode('" value="'.$row["telefono"].'" id="'.$row["telefono"].'"> '.$row["telefono"].'</a></div></td>');
  250.  
  251. $duracion=$row["sum(duracion)"];
  252. $duracion_suma=$duracion_suma+ $duracion;
  253. echo '<td> <div align=right>';
  254. echo number_format($duracion,0);
  255. echo '<div></td>';
  256.  
  257. $importe=$row["sum(importe)" ];
  258. $importe_suma= $importe_suma+ $importe;
  259. echo '<td><div><span style="float:right">';
  260. echo number_format($importe,2);
  261. echo '</span>$</div></td>';
  262. }
  263.  
  264. echo '
  265.  
  266. <tr>
  267. <td bgColor="69a9f7"> <div align=right> <strong> Total</strong> </div></td>
  268. <td bgColor="69a9f7">
  269.  
  270. <div align=right> <strong> ';
  271. echo number_format($duracion_suma,0);
  272. echo '</strong></div>';
  273.  
  274. echo '
  275.  
  276. </td>
  277. <td bgColor="69a9f7">
  278. <div><strong><span style="float:right">';
  279. echo number_format($importe_suma,2);
  280. echo '</span>$</strong></div>';
  281.  
  282. echo '</td>
  283. <tr>
  284. <br>
  285. </center>
  286. </table>';
  287. //cierra b1
  288. }
  289.  
  290. //abre b2
  291. else
  292. {
  293.  
  294.  
  295. include_once 'Conexion.php';
  296. $sql="select telefono,sum(duracion),sum(importe) from cuenta,concepto where mes_text = '".$mes."' and anio = '".$annio."' and area = '".$subdireccion."' and concepto.concepto = '".$concepto_bien."' and concepto.cve_cargo = cuenta.cve_cargo group by telefono order by sum(importe) DESC";
  297.  
  298. //$sql="select cuenta.telefono,sum(duracion),sum(importe) from cuenta,concepto where mes_text = '".$mes."' and anio = '".$annio."' and area = '".$subdireccion."' and concepto.concepto = 'EL QUE LLAMA PAGA' group by cuenta.telefono order by sum(importe) DESC";
  299. //$sql="select concepto.concepto,sum(duracion),sum(importe) from cuenta,concepto where mes_text = '".$mes."' and anio = '".$annio."' and area ='".$subdireccion."' and concepto.cve_cargo = cuenta.cve_cargo group by concepto.concepto order by sum(importe) DESC";
  300. //$sql="select concepto.concepto,sum(duracion),sum(importe) from cuenta,concepto where mes_text = '".$mes."' and anio = '".$annio."' and area ='".$subdireccion."' and concepto.cve_cargo = cuenta.cve_cargo group by concepto.concepto order by sum(importe) DESC";
  301.  
  302.  
  303. $result= mysql_query($sql) or die(mysql_error());
  304. if(mysql_num_rows($result)==0) die("No hay registros para mostrardsdsdsdsad");
  305. echo '<center><table border=1 cellpadding=4 cellspacing=0>';
  306. /*Priemro los encabezados*/
  307. echo '
  308. <th bgColor="69a9f7" width="300px"> Tel&eacutefono </th>
  309. <th bgColor="69a9f7" width="150px" > Minutos </th>
  310. <th bgColor="69a9f7" width="150px"> Importe </th>
  311.  
  312. </tr>';
  313.  
  314. /*Y ahora todos los registros */
  315.  
  316.  
  317. $duracion_suma=0;
  318. $importe_suma=0;
  319.  
  320. while($row=mysql_fetch_array($result))
  321. {
  322. $temp=utf8_encode($row["telefono"]);
  323. echo '<tr><td> <div align=left> <a onClick="verseleccion_concepto();verseleccion_conc epto();actualiza()" href="#';
  324. echo $temp;
  325. echo utf8_encode('" value="'.$row["telefono"].'" id="'.$row["telefono"].'"> '.$row["telefono"].'</a></div></td>');
  326.  
  327. $duracion=$row["sum(duracion)"];
  328. $duracion_suma=$duracion_suma+ $duracion;
  329. echo '<td> <div align=right>';
  330. echo number_format($duracion,0);
  331. echo '<div></td>';
  332.  
  333. $importe=$row["sum(importe)" ];
  334. $importe_suma= $importe_suma+ $importe;
  335. echo '<td><div><span style="float:right">';
  336. echo number_format($importe,2);
  337. echo '</span>$</div></td>';
  338. }
  339.  
  340. echo '
  341.  
  342. <tr>
  343. <td bgColor="69a9f7"> <div align=right> <strong> Total</strong> </div></td>
  344. <td bgColor="69a9f7">
  345.  
  346. <div align=right> <strong> ';
  347. echo number_format($duracion_suma,0);
  348. echo '</strong></div>';
  349.  
  350. echo '
  351.  
  352. </td>
  353. <td bgColor="69a9f7">
  354. <div><strong><span style="float:right">';
  355. echo number_format($importe_suma,2);
  356. echo '</span>$</strong></div>';
  357.  
  358. echo '</td>
  359. <tr>
  360. <br>
  361. </center>
  362. </table>';
  363. }
  364. //cierra b2
  365. }
  366. //cierro B
  367. } //cierro POST
  368. ?>[/PHP]

Etiquetas: html, mysql, tabla, url, variables, usuarios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:30.