Привет
помогите с блоком вывода комментариев на отдельной странице.
Пытался сделать по примеру выше, но ниче не получается, видать руки и голова кривые.
И вот по примеру с ponedelnikov.net пробую но нет вывода комментов
Кому не в лом подтолкните чуток.
<?php
$dbhost = "localhost";
$dbuser = "Username";
$dbpass = "Пароль БД";
$dbname = "Название БД";
$prefix = "slaed"; // Префикс таблиц, по умолчанию "slaed"
mysql_connect($dbhost, $dbuser, $dbpass) or die("Ошибка подключения к Базе данных");
mysql_select_db($dbname) or die("Ошибка в названии Базы данных");
echo "<html>
<head>
<meta http-equiv=content-type content= text/html; charset=windows-1251>
<title>Последние новости</title>
</head>
<body>";
global $prefix, $db, $dbi;
$strip = 23;
$top= "10";
## © Serg_pnz
## e-mail: print58@yandex.ru
## Site: ponedelnikov.net
## block Last Comments
/*-------------- настраиваемые параметры --------------*/
$strip = 80; #обрезка текста комментария // block Last Comments by © Serg_pnz his e-mail: print58@yandex.ru and his Site: ponedelnikov.net Good Luck
$limit = 15; #количество комментариев (тем) // block Last Comments by © Serg_pnz his e-mail: print58@yandex.ru and his Site: ponedelnikov.net Good Luck
$raz_tag = "<b><i><u>"; #разрешенные теги в комментарии. Набирать БЕЗ ПРОБЕЛОВ между тегами! // block Last Comments by © Serg_pnz his e-mail: print58@yandex.ru and his Site: ponedelnikov.net Good Luck
/*-------------- конец настраиваемые параметры --------------*/
// block Last Comments by © Serg_pnz his e-mail: print58@yandex.ru and his Site: ponedelnikov.net Good Luck
$content .= "<td valign=\"top\">";
$result = $db->sql_query("SELECT MAX(id) AS maxid, modul, cid FROM ".$prefix."_comment GROUP BY modul, cid ORDER BY maxid DESC LIMIT $limit ");
while (list($maxid, $modul, $cid) = $db->sql_fetchrow($result)) {
$mmaxid[] = $maxid;
switch($modul) {
case "Voting":
$mVoting[] = "$cid";
break;
case "News":
$mNews[] = "$cid";
break;
case "Files":
$mFiles[] = "$cid";
break;
case "Pages":
$mPages[] = "$cid";
break;
}
}
//--------- News
$const = sizeof ($mNews);
if ($const>0) {
$sql = " SELECT sid, title FROM ".$prefix."_stories WHERE ";
for ($i=0; $i<($const-1); $i++) {
$sql .= " sid='".$mNews[$i]."' OR ";
}
$sql .= " sid='".$mNews[$const-1]."' ";
$result = $db->sql_query($sql);
while(list($sid, $title) = $db->sql_fetchrow($result)) $mtNews[$sid] = $title;
}
//--------- Voting
$const = sizeof ($mVoting);
if ($const>0) {
$sql = " SELECT poll_id, poll_title FROM ".$prefix."_survey WHERE ";
for ($i=0; $i<($const-1); $i++) {
$sql .= " poll_id='".$mVoting[$i]."' OR ";
}
$sql .= " poll_id='".$mVoting[$const-1]."' ";
$result = $db->sql_query($sql);
while(list($sid, $title) = $db->sql_fetchrow($result)) $mtVoting[$sid] = $title;
}
//--------- Files
$const = sizeof ($mFiles);
if ($const>0) {
$sql = " SELECT lid, title FROM ".$prefix."_files WHERE ";
for ($i=0; $i<($const-1); $i++) {
$sql .= " lid='".$mFiles[$i]."' OR ";
}
$sql .= " lid='".$mFiles[$const-1]."' ";
$result = $db->sql_query($sql);
while(list($sid, $title) = $db->sql_fetchrow($result)) $mtFiles[$sid] = $title;
}
//--------- Pages
$const = sizeof ($mPages);
if ($const>0) {
$sql = " SELECT pid, title FROM ".$prefix."_pages WHERE ";
for ($i=0; $i<($const-1); $i++) {
$sql .= " pid='".$mPages[$i]."' OR ";
}
$sql .= " pid='".$mPages[$const-1]."' ";
$result = $db->sql_query($sql);
while(list($sid, $title) = $db->sql_fetchrow($result)) $mtPages[$sid] = $title;
}
//---------- Сам блок
$sql = " SELECT cid, modul, date, name, comment FROM ".$prefix."_comment WHERE ";
for ($i=0; $i<($limit-1); $i++) {
$sql .= " id='".$mmaxid[$i]."' OR ";
}
$sql .= " id='".$mmaxid[$limit-1]."' ORDER BY id DESC ";
$i=0;
$result = $db->sql_query($sql);
while(list($cid, $modul, $date, $name, $comment) = $db->sql_fetchrow($result)) {
$i++;
$comment = preg_replace("#\[quote\](.*?)\[/quote\]#si","",$comment);
$comment = preg_replace("#\[php\](.*?)\[/php\]#si","",$comment);
$comment = preg_replace("#\[code\](.*?)\[/code\]#si","",$comment);
$comment = preg_replace("#\[hide\](.*?)\[/hide\]#si","",$comment);
$comment = cutstr(strip_tags(bb_decode($comment), $raz_tag), $strip);
$date = formatTimestamp($date);
switch($modul) {
case "Voting":
$link = "<a href=\"index.php?name=Voting&op=poll_result&poll_id=$cid#$cid\" title=\"".$mtVoting[$cid]."\">";
break;
case "News":
$link = "<a href=\"index.php?name=News&op=article&sid=$cid#$cid\" title=\"".$mtNews[$cid]."\">";
break;
case "Files":
$link = "<a href=\"index.php?name=Files&op=view_file&lid=$cid#$cid\" title=\"".$mtFiles[$cid]."\">";
break;
case "Pages":
$link = "<a href=\"index.php?name=Pages&op=page&pid=$cid#$cid\" title=\"".$mtPages[$cid]."\">";
break;
}
$content .= "
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr style=\"padding-top: 7px;\">
<td style=\"padding-right: 5px;\">"."$link"."<img src=\"images/blocks/$modul.gif\" border=\"0\"></a></td>
<td width=\"120\">$date <b>$name</b></td>
</tr>
<tr>
<td colspan=\"2\">"."$link"."$comment</a></td>
</tr>";
if ($i!=$limit) {$content .= "";}
$content .= "</table>";
}
$content .= "</td></tr></table>";
echo "
</body>
</html>";
?>
Версия системы: SLAED CMS 2.5 Lite
Версия PHP: PHP 5
Сервер: Локальный сервер