开发者

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:

Get foreach() loop to display array output in given manner

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜