<?php 
include_once("../php/config.php");
        $sql = mysql_query("select * from clientes where CONCAT(nombre,'',telefono,'',cedula) like '%".$_GET['buscar']."%' order by nombre asc") or die(mysql_error());


?>


			
             

					
            <?php while($r=mysql_fetch_array($sql)){?>
			<?php
			$c++;
			$monto+=$r["monto"];
      $id = $r["id_cliente"];
			?>
		<a class="#"   onClick='ver(<?php echo $r["id_cliente"]?>)'><b> <?php echo $r["id_cliente"]?></b></a> 
       - <a class="#"   onClick='ver(<?php echo $r["id_cliente"]?>)'><i class="bi bi-stickies"></i><b> <?php echo $r["nombre"]?></b></a> | <?php echo ($r["telefono"])?> | <span class='text-ubuntu'><?php $ba  = balance($r["nombre"]); if($ba>0){echo $ba;}?></span> <br>
              
				
			

		
		
			

            
                                                        <?php }
												
																			
											
										$balance0=0;
										function balance($cliente){
											global $balance0;
													$sql = mysql_query("select sum(balance) as balance from ventas where cliente = '$cliente' and  balance>0") or die(mysql_error());
													$balance0+=mysql_result($sql, 0, "balance");
													return decimal(mysql_result($sql, 0, "balance"));
													
										}
										


	?>
						
