Ver Mensaje Individual
  #8 (permalink)  
Antiguo 08/02/2017, 10:06
keivis
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
Respuesta: Php mysql consulta no funciona

Gracias, aun no arroja lo que necesito. me muestra solo el resultado de una columna.
Código PHP:
Ver original
  1. <html><head>
  2. <title>CDI</title>
  3. <link  rel="stylesheet" type="text/css"  href="../../css/hojadeestilo.css">
  4. <style>
  5. table {width:99%;}
  6. #bordesc {
  7.     border: #06F 1px solid;
  8.     width: 100%;
  9.     background-color: #FFF;
  10.     border-radius: 0px;
  11.     -moz-border-radius: 0px;
  12.     -webkit-border-radius: 0px;
  13.    
  14. }
  15. </style>
  16. <style>a{cursor:pointer;}</style>
  17. </head>
  18. <body>
  19. <div class="tablas"></div>
  20. <table  border="0" cellspacing="0" cellpadding="4" align="center">
  21.               <tr>          
  22.               <td><p align="center"><b>Estado de los medicamentos</b></p></td>            
  23.               </tr>
  24.            </table>        
  25. <tr>  <tr>
  26.         <td height="125" align="center">
  27.   <table  border="0" cellspacing="0" cellpadding="4" align="center">
  28.               <tr>
  29. <td>
  30.   <?php
  31. include ("../../../funciones/conexion.php");
  32. $con = mysqli_connect($host, $user, $pass) or die("Error al conectarse al servidor");
  33. mysqli_select_db($con, $db) or die("Error al conectarse a la base de datos");
  34. $resultingreso = mysqli_query($con, "SELECT  cantidad_recibida,medicamento FROM medicina GROUP BY cantidad_recibida");  
  35. $resultegreso = mysqli_query($con, "SELECT  cantidad_entregada FROM entrega GROUP BY cantidad_entregada");
  36.  
  37. if (mysqli_num_rows($resultingreso) > 0)
  38. if (mysqli_num_rows($resultegreso) > 0)
  39.  
  40. {
  41. ?>
  42. <table border="1" width="100%" id="bordesc">
  43. <tr>
  44. <th>Medicina</th>
  45. <th>Ingreso</th>
  46. <th>Egreso</th>
  47. <th>Disponible</th>
  48. </tr>
  49. <?php
  50.  
  51. while ($datos = mysqli_fetch_array($resultingreso))
  52. while ($resultegre = mysqli_fetch_array($resultegreso))
  53. {
  54. $totaling=$datos['cantidad_recibida'];
  55. $totalegre=$resultegre['cantidad_entregada'];
  56. $saldo = $totaling - $totalegre;
  57. ?>
  58. <tr>
  59. <td align="center"> <?=$datos["medicamento"]?></td>
  60. <td align="center"> <?=$datos["cantidad_recibida"]?> Bs</td>
  61. <td align="center"><?=$resultegre["cantidad_entregada"]?> Bs</td>
  62. <td align="center"><?php echo''.$saldo.'';?> Bs</td>
  63. </tr>
  64. <?php
  65. }
  66. ?>
  67. </table>
  68. <?php
  69. } else {
  70. echo "No se encontraron datos en la base de datos";
  71. }
  72. ?>
  73.  
  74.  <p align="right"><a href="http://www.forosdelweb.com/index.php"></a></p></td></tr></table>
  75.   </body>
  76.   </html>