PHP
<?php
$result = $sth->fetchAll(PDO::FETCH_NUM);
print_r($result); //or var_dump($result); for more info
foreach($result as $row){
$half = array_splice($row,0,5);
echo implode(" ",$half)."<br /><br />Merchant Offered:<br />".implode(" ",$row);
}
?>
SQL
SELECT uFName, uLName, listTitle, listPropPrice, listCmt, listDt, mFName, mLName, moAmt, moDtOff
FROM User U, Listing L, Merchant M, MerchantOffer MO
WHERE U.uID = L.uID
and L.listID = MO.listID
and M.mID = MO.mId
Currently outputting: http://i.stack.imgur.com/qAtcf.png
How do I get it to NOT output the first big array :
Array ( [0] => Array ( [0] => Joseph [1] => Dickinson [2] => Need Xbox 360 [3] => 150 [4] => I need one quick! [5] => 2011-09-15 [6] => John [7] => Doe [8] => 149.99 [9] => 2011-09-15 ) [1] => Array ( [0] => Joseph [1] => Dickinson [2] => Need Xbox 360 [3] => 150 [4] => I need one quick! [5] => 2011-09-15 [6] => Jane [7] => Doe [8] => 154.99 [9] => 2011-09-15 ) [2] => Array ( [0] => Joseph [1] => Dickinson [2] => Need Xbox 360 [3] =&g开发者_运维技巧t; 150 [4] => I need one quick! [5] => 2011-09-15 [6] => Diana [7] => Matthews [8] => 160.00 [9] => 2011-09-15 ) [3] => Array ( [0] => Joseph [1] => Dickinson [2] => Need Xbox 360 [3] => 150 [4] => I need one quick! [5] => 2011-09-15 [6] => Amanda [7] => Koste [8] => 174.99 [9] => 2011-09-15 ) [4] => Array ( [0] => Warren [1] => Kennan [2] => Need New Sofa [3] => 1000 [4] => Need one quick [5] => 2011-09-15 [6] => Diana [7] => Matthews [8] => 495.99 [9] => 2011-09-15 ) [5] => Array ( [0] => Warren [1] => Kennan [2] => Need New Sofa [3] => 1000 [4] => Need one quick [5] => 2011-09-15 [6] => Amanda [7] => Koste [8] => 489.99 [9] => 2011-09-15 ) ) Joseph Dickinson Need Xbox 360 150 I need one quick!
and instead TO POST the output like:
Joseph Dickinson Need Xbox 360 150 I need one quick!
Merchant Offered:
2011-09-15 John Doe 149.99 2011-09-15
Thanks
Try something like that
The code
<?php
...
// Do a loop on each row of your result / repeat the display
foreach ($result as $row) {
for ($i=0;$i<=count($row); $i++) {
echo $row[$i].' ';
if ($i==6) {
echo '<br/><br/>Merchant Offered:<br/>';
}
}
echo '<br/><br/>';
}
Output would be
Joseph Dickinson Need Xbox 360 150 I need one quick!
Merchant Offered:
2011-09-15 John Doe 149.99 2011-09-15
Joseph Dickinson Need Xbox 360 150 I need one quick!
Merchant Offered:
2011-09-15 Jane Doe 149.99 2011-09-15
...
Two stuff:
Not sure output would be exactly what you need, do you really want to repeat the user request on each line or do you want one time and after all merchantoffer? like below
Joseph Dickinson Need Xbox 360 150 I need one quick! Merchant Offered: 2011-09-15 John Doe 149.99 2011-09-15 2011-09-15 Jane Doe 149.99 2011-09-15 ...
In that case you need to add an identifier on people request to group the line for example...
Maybe you can concatenate your informations into your sql statement to improve the readability of your code and avoid the line : if ($i==6) which doesn't really represents something understandable.
精彩评论