Mam następujący problem. Posiadam portal oraz IPB niezintegrowane ze soba, ale na portalu chciałbym wyświetlać 10 najnowszych wątków z forum. Znalazłem następujący skrypt:
Kod
$con = mysql_connect('localhost', '***', '***') or die(mysql_error());
mysql_select_db('***') or die(mysql_error());
$limit='13';
$strAdr='http://site.adress';
$strPfx='ibf_';
$r=mysql_query('SELECT t.last_post, t.tid, t.title, t.views, t.posts, t.start_date, t.starter_name, t.last_poster_name, t.last_poster_id, t.approved, t.forum_id, f.name, f.id
FROM '.$strPfx.'topics t
LEFT JOIN '.$strPfx.'forums f ON (t.forum_id = f.id)
GROUP BY t.title
ORDER BY t.last_post DESC LIMIT 0,'.$limit.'');
while($row=mysql_fetch_array($r)){
$strT=$row['title'];
if (strlen($strT)>30)
{
$strT = substr( $strT, 0, 400 ) . '.';
}
if ($row['approved'] == 1) {
echo'<a href="'.$strAdr.'/index.php?index.php&showtopic='.$row['tid'].'" target="_blank" class="side">'.trimlink($strT, 40).'</a><br>
';
}
}
mysql_select_db('***') or die(mysql_error());
$limit='13';
$strAdr='http://site.adress';
$strPfx='ibf_';
$r=mysql_query('SELECT t.last_post, t.tid, t.title, t.views, t.posts, t.start_date, t.starter_name, t.last_poster_name, t.last_poster_id, t.approved, t.forum_id, f.name, f.id
FROM '.$strPfx.'topics t
LEFT JOIN '.$strPfx.'forums f ON (t.forum_id = f.id)
GROUP BY t.title
ORDER BY t.last_post DESC LIMIT 0,'.$limit.'');
while($row=mysql_fetch_array($r)){
$strT=$row['title'];
if (strlen($strT)>30)
{
$strT = substr( $strT, 0, 400 ) . '.';
}
if ($row['approved'] == 1) {
echo'<a href="'.$strAdr.'/index.php?index.php&showtopic='.$row['tid'].'" target="_blank" class="side">'.trimlink($strT, 40).'</a><br>
';
}
}
Wszystko fajnie działa, tylko skrypt ten wyświetla również tematy z forum które jest tylko dla "szefostwa". Forum ma numer 22 i nie bardzo wiem co powinienem dodać, by te tematy były pomijane.
Z góry dzięki za pomoc.