Giriş aşağıdaki ters kronolojik sırayla "datesubmitted" adı verilen bir zaman damgası alanı ile gönderimler sıralar. Bu alan adında bir MySQL tablo olduğunu "teslim."
Başka bir MySQL tablo "yorum" adı verilen başka bir zaman damgası alanı var "datecommented."
Her gönderme tek "datesubmitted" var ama birkaç yorum, her biri farklı bir olabilir "datecommented."
Nasıl "datesubmitted" ve her birinin son "datecommented" tarafından başvuru sıralamak? Diğer bir deyişle, bu listenin üst most son zamanlarda oluştu hangisi en son açıklama, ile en son teslim girişi veya giriş ya da göstermek istiyorum.
Teşekkür peşin,
John
$sqlStr = "SELECT
s.loginid
,s.title
,s.url
,s.displayurl
,s.datesubmitted
,l.username
,s.submissionid
,COUNT(c.commentid) countComments
FROM
submission s
INNER
JOIN
login l
ON
s.loginid = l.loginid
LEFT OUTER
JOIN
comment c
ON
s.submissionid = c.submissionid
GROUP
BY
s.submissionid
ORDER
BY
s.datesubmitted DESC
LIMIT
10";
$tzFrom = new DateTimeZone('America/New_York');
$tzTo = new DateTimeZone('America/Phoenix');
// echo $dt->format(DATE_RFC822);
$result = mysql_query($sqlStr);
$arr = array();
echo "<table class=\"samplesrec\">";
while ($row = mysql_fetch_array($result)) {
$dt = new DateTime($row["datesubmitted"], $tzFrom);
$dt->setTimezone($tzTo);
echo '<tr>';
echo '<td class="sitename1"><a href="http://www.'.$row["url"].'" TARGET="_blank">'.$row["title"].'</a> <div class="dispurl">'.$row["displayurl"].'</div></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="sitename2name">Submitted by <a href="http://www...com/.../members/index.php?profile='.$row["username"].'">'.$row["username"].'</a> on '.$dt->format('F j, Y &\nb\sp &\nb\sp g:i a').'</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="sitename2"><a href="http://www...com/.../comments/index.php?submission='.$row["title"].'&submissionid='.$row["submissionid"].'&url='.$row["url"].'&countcomments='.$row["countComments"].'&submittor='.$row["username"].'&submissiondate='.$row["datesubmitted"].'&dispurl='.$row["displayurl"].'">'.$row["countComments"].' comments</a></td>';
echo '</tr>';
}
echo "</table>";