Gå til innhold

siste fra forum skript (phpBB2)


Anbefalte innlegg

Videoannonse
Annonse

Fikk denne fra Amund en gang, funker fint. Legg til flere kategorier på cat_id om flere skal vises.

<?



$dbhost = "forum.hardware.no";

$cat_id = 1;



include("../../config.php");

$conn = @mysql_connect($dbhost, $dbuser, $dbpasswd);



$kategorisql = "SELECT forum_id FROM phpbb_forums WHERE cat_id = '$cat_id'";

$res = @mysql_db_query($dbname, $kategorisql, $conn);

$forum_antall = @mysql_num_rows($res);



$sql = "SELECT * FROM phpbb_topics WHERE ";



for ($i = 0; $i < $forum_antall; $i++) {

$tmp = mysql_fetch_array($res);

$forums[$i] = $tmp[forum_id];

$sql .= "forum_id = $tmp[forum_id] ";

if ($i < ($forum_antall - 1))

  $sql .= "OR ";

}



$sql .= "ORDER BY topic_time DESC";



$res = @mysql_db_query($dbname, $sql, $conn);

$antall = mysql_num_rows($res);

for ($i = 0; $i < 10; $i++) {

$nyheter = mysql_fetch_array($res);

$svar = $nyheter[topic_replies];

$forumid = $nyheter[forum_id];

$svar = $svar + 1;

if($i < $antall) {

  echo "<a href="http://forum.hardware.no/viewtopic.php?topic=$nyheter[topic

_id]&forum=$forumid">";

  if (strlen($nyheter[topic_title]) > 18) {

    echo substr($nyheter[topic_title], 0, 15) . "...";

  }

  else {

    echo $nyheter[topic_title];

  }

  echo "</a> (" . $svar . ")<br>";

}

}



mysql_close();



?>

Lenke til kommentar
  • 3 uker senere...

Hei!!!

 

jeg lurte på om denne vil fungere med db fra en phpnuke.

 


<?

$cat_id = 1;

include("config.php");


$connect = mysql_connect("$user_hostname", "$user_username", "$user_password");
mysql_select_db("$user_database", $connect);


$kategorisql = "SELECT forum_id FROM nukebb_forums WHERE cat_id = '$cat_id'";

$res = @mysql_db_query($dbname, $kategorisql, $conn);

$forum_antall = @mysql_num_rows($res);



$sql = "SELECT * FROM nukebb_topics WHERE ";



for ($i = 0; $i < $forum_antall; $i++) {

$tmp = mysql_fetch_array($res);

$forums[$i] = $tmp[forum_id];

$sql .= "forum_id = $tmp[forum_id] ";

if ($i < ($forum_antall - 1))

 $sql .= "OR ";

}



$sql .= "ORDER BY topic_time DESC";



$res = @mysql_db_query($dbname, $sql, $conn);

$antall = mysql_num_rows($res);

for ($i = 0; $i < 10; $i++) {

$nyheter = mysql_fetch_array($res);
$svar = $nyheter[topic_replies];

$forumid = $nyheter[forum_id];

$svar = $svar + 1;

if($i < $antall) {

 echo "<a href='http://xxxxx/viewtopic.php?topic=$nyheter[topic_id]&forum=$forumid'>";

 if (strlen($nyheter[topic_title]) > 18) {

   echo substr($nyheter[topic_title], 0, 15) . "...";

 }

 else {

   echo $nyheter[topic_title];

 }

 echo "</a> (" . $svar . ")<br>";

}

}



mysql_close();



?>

Endret av jic
Lenke til kommentar
Gjest Slettet+432

Pleier å bruke denne, veldig enkel.

 

<?PHP

$dbhost = "dbserver"; /* Databaseserver */
$dbname = "dbnavn"; /* Databasenavn */
$dbuser = "dbbruker"; /* Databasebruker */
$dbpasswd = "dbpassord"; /* Databasepassord */
$phpbb_dir = "forum/"; /* phpBB sin rotmappe */
$table_prefix = "phpbb_";
$postcount = 5;  /* Her bestemmer du hvor mange poster som skal vises. */

$db = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Couldn't connect");
mysql_select_db($dbname, $db) or die("Couldn't select database.");

$result = mysql_query("SELECT DISTINCT posts.topic_id, topics.topic_title FROM
{$table_prefix}posts as posts LEFT JOIN {$table_prefix}topics as topics ON
topics.topic_id = posts.topic_id LEFT JOIN {$table_prefix}forums as forums ON
forums.auth_view = 0 WHERE topics.forum_id = forums.forum_id GROUP BY
posts.topic_id ORDER BY posts.post_time desc LIMIT {$postcount}");

while($row = mysql_fetch_row($result)) {
   echo "<a href=\"{$phpbb_dir}viewtopic.php?t={$row[0]}\" target=\"_blank\">" . $row[1] .
"</a><br>";
}

?>

 

Edit: Hvis du skal bruke den på nuke, så går det kanskje ikke så bra, nei....

Endret av Slettet+432
Lenke til kommentar

For PHPBB:

 

http://phpbbfetchall.sourceforge.net/

 

phpBB Fetch All is a modification to phpBB that displays data from the forum on any page of a website. It supports all phpBB versions from the 2.0.x branch.

 

For Invision Power Board:

 

http://mods.ibplanet.com/db/?mod=1791

 

Dette er en klasse som gir tilgang til flere funksjoner og databaseintegrasjon. Det er også inkludert flere eksempel script, blant news, siste poster m.m.

 

IPB SDK is a powerful development tool, which will allow you to develop advanced applications with ease. Integration between your forum and site is essential in the websites of today. IPB already has a great member system, why re-write another one if you can use one member database for both?

 

Our huge array of functions include contact, custom profile field, forum, member, posts, poll, private messaging, skin, and topic functions. Whether your just looking to display the current users avatar, memberbar, create a PM system on your website, utilitize IPB's member database for other scripts, or allow members to register, and login from your website, IPB SDK is for you.

 

IPB SDK also contains several code examples, which utilitize this mod, which can be placed in your own scripts, giving you instant customizable site integration.

Endret av DexterBlasted
Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...