I am creating a sales system and would like to list the quantity sold for each product. So I would not repeat the name of the product, but only the quantity sold.
ThewayIdidislikethisbutIwouldlikesuggestions.
<?phpif($_GET['busca']=="data"){
$datai = date('Y/m/d', strtotime($_POST['datai']));
$dataf = date('Y/m/d', strtotime($_POST['dataf']));
$hora1 = $_POST['hora1'];
$hora2 = $_POST['hora2'];
$garcon = $_POST['idGarcon'];
$query = mysqli_query("SELECT data, nome, preco, SUM(preco) AS pr, SUM(qtd) AS qtd, date_format(data, '%d/%m/%Y') AS data FROM tbl_carrinho WHERE idGarcon='$garcon' AND data BETWEEN '$datai' AND '$dataf' AND time BETWEEN '$hora1' AND '$hora2' GROUP BY data") or die(mysqli_error());
$sel = mysqli_query("SELECT * FROM tbl_carrinho")or die(mysqli_error());
while($resultado = mysqli_fetch_array($query)){
$ids = $resultado['idGarcon'];
$oo = mysqli_query("SELECT * FROM garcon WHERE idGarcon='$garcon'")or die(mysqli_error());
$todos = mysqli_fetch_assoc($oo);
$nome_garcon = $todos['nomeGarcon'];
$data = $resultado['data'];
$nome = $resultado['nome'];
$qtd = $resultado['qtd'];
$preco_unitario = $resultado['preco'];
$precototal = $resultado['pr'];
$total_produto = $qtd * $preco_unitario;
$total += $total_produto;
$comi = mysqli_query("SELECT * FROM config");
$valor = mysqli_fetch_array($comi);
$venda = $valor['pgarcon'];
$ganho += $total_produto * $venda / 100;
?>