I am having some problems, trying to get data from my database, and show it correctly. I have a layout, where I have two "lists", where I can add rows to each lists. I can add multiple rows to each list.
I want to display the output, so the first list, along with all it's row is showed first and then the second list, along with it's rows.
Currently, it is showed like this:
LIST #1
-- row inside list #1 --
-- row inside list #1 --
LIST #2
-- row inside list #2 --
Currently, it is displaying like this:
LIST #1
-- row inside list #1 --
LIST #2
-- row inside list #2 --
LIST #1
-- row inside list #1 --
Below is a visual:
This is my selection in PHP:
$driving=$dbh->prepare("SELECT
driving_lists.id,
driving_lists.list_id,
driving_lists.date,
driving_lists.list_name,
driving_list_shipments.*
FROM
driving_lists
LEFT JOIN driving_list_shipments ON driving_lists.list_id = driving_list_shipments.list_id
");
$driving->execute();
And the output script:
foreach( $driving as $row){
echo "<pre>";
echo $row["list_name"];
echo "<br />";
echo $row["reference"];
echo "</pre>";
}
What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…