gottaloveit 44 Newbie Poster

Agree with Biiim, you need to loop through the results. example below. note I took the body out of the loop.

<?php

                                /*error_reporting(E_ALL);
                                ini_set('display_errors', 1);*/

                                $CustomerName = $_GET['customername'];
                                //echo htmlentities($CustomerName);

                                $sql = "SELECT 
                                                    tblorders.InvoiceNumber,
                                                    tblorders.LorryName,
                                                    tblorders.CustomerName,
                                                    tblorders.DeliveryDate,
                                                    tblorders.PaymentMode,
                                                    tblorders.DeliveryMethod,
                                                    GROUP_CONCAT(CONCAT(tblorders.Quantity, ' of ', tblproducts.ProductName) SEPARATOR ', ') AS productnames, 
                                                    tblorders.InvoiceGenDate
                                                FROM tblorders 
                                                JOIN tblproducts ON tblproducts.id = tblorders.ProductId
                                                JOIN tblcustomers ON tblorders.CustomerName = tblcustomers.customername
                                                WHERE tblorders.CustomerName = :CustomerName";

                                $statement = $dbh->prepare($sql);
                                $statement->bindValue(':CustomerName', $CustomerName);
                                $result = $statement->execute();

                                if(!$result)
                                {
                                    //Query failed
    echo "Query failed";
    //Add debugging code
                                }
                                elseif(!$statement->rowCount())
{
    //No results returned
    echo "No user found for user " . htmlentities($CustomerName);
   //Add debugging code
}
                                else
{
?>
                                <tbody>
 <?php
    //A record was returned, display results
    while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {

                                    ?>


                                    <tr>
                                        <td><?php echo $row['InvoiceNumber']; ?></td>
                                        <td><?php echo $row['LorryName'] ;?></td>
                                        <td><?php echo htmlentities(date("d-m-Y", strtotime($row['DeliveryDate'])));?></td>
                                        <td><?php echo $row['PaymentMode'];?></td>
                                        <td><?php echo $row['DeliveryMethod'];?></td>
                                        <td><?php echo htmlentities(date("d-m-Y", strtotime($row['InvoiceGenDate'])));?></td>
                                        <td><?php echo $row['productnames'];?></td>
                                        <td class="project-actions text-right">
                                        <a class="btn btn-primary btn-sm" href="#">View Invoice</a></td>
                                    </tr>
<?php } ?>
                            </tbody>

                            <?php

    //echo "Start Date: {$row['CustomerName']}<br/>\n";
}

$statement->closeCursor();
                                ?>
Biiim commented: You need to remove the GROUP_CONCAT, it merges together all rows and is the problem he is having -2