
31-03-2009, 23:19
|
|
|
|
חבר מתאריך: 16.03.06
הודעות: 80
|
|
זה הקוד:
קוד PHP:
$sql= "
SELECT `id` FROM `forum`
WHERE `deleted` = 0
AND `father` = 1
ORDER BY `tack` DESC,
(IF(`date_update` - `date_creation` - 30001 < 0, 0, 1)) ASC
LIMIT 0,30
";
$get_sql = mysql_query($sql);
$childs = '(';
while ($line = mysql_fetch_array($get_sql)) {
$roots[] = $line;
$childs .= "{$line['id']},";
}
$childs = substr($childs, 0, strlen($childs) - 1) . ')';
$sql= "
SELECT `id`, `title`, `article`, `date_creation`, `tack`
FROM `forum`
WHERE `deleted` = 0
AND
`root` IN ".$childs."
ORDER BY `root` ASC,`genes` ASC;
";
$get_sql = mysql_query($sql);
while ($row = mysql_fetch_array($get_sql))
echo $row['id']." ".$row['title']." ".$row['article']." ".$row['date_creation']." ".$row['tack']."<br />";
וזה עובד כמובן עם שילוב של PHP אבל מי שמוצא את הדרך לכתוב את זה רק בSQL זה יהיה
תודה לכל העוזרים 
|