我正在尝试实现以下输出:
//
Joseph Dickinson
Title: Need Xbox 360
Comment: I need one quick!
on 2011-09-15
John Doe 149.99
Jane Doe 154.99
Diana Matthews 160.00
Amanda Koste 174.99
//
目前,我为“John Doe 149.99”或“Jane Doe 154.99”等每个优惠写了“Joseph Dickinson”这个名字。我希望每个人都有一个标题,如“需要Xbox 360”
此页面通过php文件收集此信息:
<?php require_once('inc/db/dbc.php'); ?>
<?php
#GET User (Buyer) Info and General Listing Info
$pdo = new PDO($h1, $u, $p);
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth = $pdo->prepare('
SELECT uFName, uLName, listTitle, listCmt, listDt, mBCFName, mBCLName, 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
LIMIT 0,5
;');
$sth->execute(array());
?>
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("<br> ",$half)."<br />".implode(" ",$row);
}
?>
如何以上面列出的方式输出?使用数组索引会更容易吗?我如何实现// //以上?