geofox

Grafico PHP

Jan 6th, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.61 KB | None | 0 0
  1. <?php include("header.php");
  2.  
  3. function contar_ventas(){
  4.  
  5. $lista = array();
  6. $consulta="SELECT estado,COUNT(codventa) as total from envios
  7. where estado IN('Pendiente','Despachado','Confirmada')
  8. group by  estado order by estado desc";
  9. $rs=mysql_query($consulta) or die("Error en la consulta"); 
  10. while  ($fila= mysql_fetch_assoc($rs)){
  11.                          
  12. $lista[] = $fila;
  13.            
  14.              
  15.  }
  16.  
  17. return $lista;
  18.  
  19. }
  20.  
  21. function canceladas(){
  22.  
  23. $lista = array();
  24. $consulta="SELECT COUNT(codventa) as total from envios
  25. where estado IN('Cancelada por el Cliente','Cancelada por el Sistema')";
  26. $rs=mysql_query($consulta) or die("Error en la consulta"); 
  27. while  ($fila= mysql_fetch_assoc($rs)){
  28.                          
  29. $lista[] = $fila;
  30.            
  31.              
  32.  }
  33.  
  34. return $lista;
  35.  
  36. }
  37.  
  38.  
  39. ?>
  40.  
  41.  
  42. <div id="content">
  43.    
  44.     <div class="container">
  45.    
  46.            
  47.        
  48.         <div class="span9">
  49.                
  50.                
  51.                
  52.                 <div class="stat-container">
  53.                         <?php
  54.                            
  55.                             $lista = contar_ventas();
  56.                        
  57.                             if(count($lista)>0){
  58.                             for($i=0;$i<count($lista);$i++) {
  59.                             ?>             
  60.                    
  61.                     <div class="stat-holder">                      
  62.                         <div class="stat">                         
  63.                             <span><?php echo $lista[$i]["total"]; ?></span>                        
  64.                             <?php
  65.                            
  66.                             echo $lista[$i]["estado"];
  67.                            
  68.                            
  69.                             ?>                 
  70.                         </div> <!-- /stat -->                      
  71.                     </div> <!-- /stat-holder -->
  72.                    
  73.                                    
  74.                
  75.                     <?php } }
  76.                         $canceladas = canceladas();
  77.                         if (count($canceladas)>0){
  78.                     ?>
  79.                    
  80.                     <div class="stat-holder">                      
  81.                         <div class="stat">                         
  82.                             <span><?php echo $canceladas[0]["total"]; ?></span>                        
  83.                             Canceladas             
  84.                         </div> <!-- /stat -->                      
  85.                     </div> <!-- /stat-holder -->
  86.                     <?php }  ?>
  87.                 </div> <!-- /stat-container -->
  88.                
  89.                 <div class="widget">
  90.                                        
  91.                     <table id='myTable5'>
  92.                 <caption></caption>
  93.                 <thead>
  94.                     <tr>
  95.                         <th></th>
  96.                         <?php for($i=0;$i<count($lista);$i++) { ?>
  97.                         <th><?php
  98.                            
  99.                             echo $lista[$i]["estado"];
  100.                            
  101.                            
  102.                             ?>  </th>
  103.                         <?php }  ?>
  104.                        
  105.                     </tr>
  106.                 </thead>
  107.                     <tbody>
  108.                     <tr>
  109.                         <th></th>
  110.                         <?php for($i=0;$i<count($lista);$i++) { ?>
  111.                         <td><?php
  112.                            
  113.                             echo $lista[$i]["total"];
  114.                            
  115.                            
  116.                             ?> 
  117.                         <?php }  ?>
  118.                        
  119.                         </td>
  120.                    
  121.                     </tr>
  122.                 </tbody>
  123.             </table>
  124.                 </div>
  125.            
  126.            
  127.                
  128.                    
  129.                 </div> <!-- /widget -->
  130.            
  131.                
  132.            
  133.                
  134.                
  135.                
  136.            
  137.                
  138.             </div> <!-- /span9 -->
  139.            
  140.            
  141.         </div> <!-- /row -->
  142.        
  143.     </div> <!-- /container -->
  144.    
  145. </div> <!-- /content -->
  146.  
  147.  
  148. <?php include("footer.php"); ?>
Advertisement
Add Comment
Please, Sign In to add comment