我正在尝试为每个商家信息(又名listID
)获取listTitle
,listCmt
,但是对于列表中的listID
等于{的每一行listID
(MerchantOffer
)中的{1}}。如何使用php迭代mysql中的所有匹配?
我尝试使用:
moID PK
SQL
<?php
$result = $sth->fetchAll(PDO::FETCH_ASSOC);
require_once('inc/php/timeAgo.php');
echo $then;
foreach($result as $row)
{
echo "<div class='listing'>";
print '<br>Title: ' . $row['listTitle'] . '<br>Comment: ' . $row['listCmt']
. '<br><br>' . $days . ' days ' . $hours . ' hours ago' . '<br><br>' .
. '<br>Offer By: ' . $row['mBCFName']. ' ' .$row['mBCLName']. '<br> for: '
. $row['moAmt'];
echo "</div>";
}
?>
但是,它并没有给我我想要的东西:
SELECT listTitle, listLength, listCmt, listDt
FROM User U, Listing L, Merchant M, MerchantOffer MO
WHERE U.uID = L.uID
and L.listID = MO.listID
and M.mID = MO.mId
GROUP BY listTitle
ORDER BY listDt DESC;