Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Zapytanie do bazy IPB
Forum PHP.pl > Forum > Bazy danych > MySQL
bobeq
Witam

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>
';
}
}


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.
AxZx
  1. 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
  2. FROM '.$strPfx.'topics t
  3. LEFT JOIN '.$strPfx.'forums f ON (t.forum_id = f.id)
  4. GROUP BY t.title
  5. ORDER BY t.last_post DESC LIMIT 0,'.$limit


zgaduje:
  1. 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
  2. FROM '.$strPfx.'topics t
  3. LEFT JOIN '.$strPfx.'forums f ON (t.forum_id = f.id)
  4. WHERE t.forum_id = 22
  5. GROUP BY t.title
  6. ORDER BY t.last_post DESC LIMIT 0,'.$limit
bobeq
Raczej powinno być
  1. WHERE t.forum_id <> 22
ale o to chodziło. smile.gif Pięknie dziękuję.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.