<?php
include_once '../php/config.php';
mysql_query("update mesas set total=0 where estado='Disponible'") or die(mysql_error());

$ah =  mysql_query("select * from mesas") or die(mysql_error());
while($s = mysql_fetch_array($ah)){
	$mesa = $s["nombre"];
	mysql_query("update mesas set total='".total($mesa)."'  where nombre='".$mesa."'") or die(mysql_error());

}
	
function total($mesa){
	$ah =  mysql_query("select sum(total_precio) as total from detalle_comanda where mesa='$mesa' and anulado!=1") or die(mysql_error());
	return @mysql_result($ah, 0, "total");
	//echo mysql_result($ah, 0, "total");

}


	
	?>