8722 sujets

Développement web côté serveur, CMS

Bonjour,
J'ai crée un code php pour exporter des commandes prestashop, dans un tableau html.
J'aimerais n'afficher qu'une colonne par client, avec la quantité du produit commandé.
Une petite piste ?
Merci
<?php  
     
$mysqli = new mysqli();
 
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
                            }
 
$query =    'SELECT od.product_id, od.product_name, m.name, oh.id_order_state, CONCAT (c.firstname) as firstname, SUM(od.product_quantity) as totalquantity, od.product_quantity as quantityperusers
                    FROM zeoi_order_detail od
                    LEFT JOIN  zeoi_orders o ON (od.id_order = o.id_order)
                    LEFT JOIN  zeoi_product p ON (od.product_id = p.id_product)
                    LEFT JOIN  zeoi_manufacturer m ON (p.id_manufacturer = m.id_manufacturer)
                    LEFT JOIN  zeoi_customer c ON (c.id_customer = o.id_customer)
                    LEFT JOIN  zeoi_order_history oh ON (oh.id_order = od.id_order)
            WHERE oh.id_order_state = 10
                    GROUP BY od.product_id, od.product_attribute_id
                    ORDER BY od.product_id';
 
$result = $mysqli->query($query);
while($row = $result->fetch_array())
{
$rows[] = $row;
}
?>
<table style="center">
    <tr>
    <td> Nom du produit </td>
    <td> Marque </td>
    <td> Quantité total commandé </td>
<?php
       foreach($rows as $row)
{
echo  "<td>".$row['firstname'] . "</td>";
}
?>
    </tr>
    <tr>
     <?php
foreach($rows as $row){
echo "<td>". $row['product_name'] . "</td>";
echo "<td>". $row['name'] . "</td>";
echo  "<td>".$row['totalquantity'] . "</td>";
echo  "<td>".$row['quantityperusers'] . "</td></tr>";
}?>
</table>
<?php
 /* free result set */
$result->close();
/* close connection */
$mysqli->close();
?>


upload/1510478967-68382-capturedaeacran2017-11-12aa09.png
Modifié par ouslie (12 Nov 2017 - 10:29)