Get foreach() loop to display array output in given manner
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
PHP
<?php
$result = $sth->fetchAll();
print_r($result); //or var_dump($result); for more info
foreach($result as $row){
print_r($row);
}
?>
Kolinks output:
Why is it duplicating everything twice??
Try this:
$half = array_splice($row,0,5);
echo implode(" ",$half)."<br /><br />Merchant Offered:<br />".implode(" ",$row);
Basically it extracts the first five values and concatenates them with space, then puts in the "Merchant Offered" text, then concatenates the remaining values.
精彩评论