Seite 1 von 2

Display Recent Topics on any page.

Verfasst: 26.02.2003 19:05
von mario8
hallo leute !

kann mir jemand erklären wie ich das machen muss:
<?php
/* Basic config */
$topicnumber = 10; /*+++ Number of topics you want to display +++*/
$scroll = "up"; /*+++ Scroll "down" or "up" */

/* Database config */
include 'forum/config.php'; /*+++ Replace "XXX" with relative or URL path of your forum directory. +++*/
/*+++ Example (Relative Path): phpBB2, forum, board, etc. +++*/
/*+++ Example (URL Path): http://www.phpbb.com/phpBB2 +++*/


/* Connecting, selecting database */
$table_topics = $table_prefix. "topics";
$table_forums = $table_prefix. "forums";
$table_posts = $table_prefix. "posts";
$table_users = $table_prefix. "users";
$link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");
mysql_select_db("$dbname") or die("Could not select database");

/* Performing SQL query */
$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
t.topic_status <> 2 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id
ORDER BY p.post_id DESC LIMIT $topicnumber";
$result = mysql_query($query) or die("Query failed");

/* Printing results in HTML */

print "<marquee id=\"recent_topics\" behavior=\"scroll\" direction=\"$scroll\" height=\"200\" scrolldelay=\"100\" scrollamount=\"2\">
<table cellpadding='4' cellSpacing='1' width='550'>";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<tr valign='top'><td>" .
$row["topic_title"] .
"</td><td>" .
$row["username"] .
"</td><td>" .
date('F j, Y, g:i a', $row["post_time"]) .
"</td></tr>";
}
print "</table></marquee>";

/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);
?>
ist das so richtig??
<?php
/* Basic config */
$topicnumber = 10; /*+++ Number of topics you want to display +++*/
$scroll = "up"; /*+++ Scroll "down" or "up" */

/* Database config */
include 'forum/config.php'; /*+++ Replace "XXX" with relative or URL path of your forum directory. +++*/
/phpBB2/
/http://www.ferrum-noricum.comball.net/phpBB2/


/* Connecting, selecting database */
$table_topics = $table_prefix. "topics";
$table_forums = $table_prefix. "forums";
$table_posts = $table_prefix. "posts";
$table_users = $table_prefix. "users";
$link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");
mysql_select_db("$dbname") or die("Could not select database");

/* Performing SQL query */
$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
t.topic_status <> 2 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id
ORDER BY p.post_id DESC LIMIT $topicnumber";
$result = mysql_query($query) or die("Query failed");

/* Printing results in HTML */

print "<marquee id=\"recent_topics\" behavior=\"scroll\" direction=\"$scroll\" height=\"200\" scrolldelay=\"100\" scrollamount=\"2\">
<table cellpadding='4' cellSpacing='1' width='550'>";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<tr valign='top'><td>" .
$row["topic_title"] .
"</td><td>" .
$row["username"] .
"</td><td>" .
date('F j, Y, g:i a', $row["post_time"]) .
"</td></tr>";
}
print "</table></marquee>";

/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);
?>
danke
mario

Verfasst: 26.02.2003 20:20
von nicmare
nimm lieber nen anderen hack ;)

-> der ist besser: http://www.acidjunky.de/extra/recent_min_303.zip thx@acid

Verfasst: 26.02.2003 20:42
von mario8
sonnst kann mir keiner helfen???

grüsse
mario

Verfasst: 27.02.2003 11:30
von Acid
/* Database config */
include 'forum/config.php'; /*+++ Replace "XXX" with relative or URL path of your forum directory. +++*/
/*+++ Example (Relative Path): phpBB2, forum, board, etc. +++*/
/*+++ Example (URL Path): http://www.phpbb.com/phpBB2 +++*/
Du musst die Markierungen (/*) schon so lassen, da´s nur Hilfestellungen sind, aber ka genutzter Code. Ansonsten stimmt es eigentlich (also entweder gibst Du nur´n Ordner an (forum) oder die komplette Url (http://..).

Verfasst: 27.02.2003 15:27
von saerdnaer
wobei ich mit nicht vorstellen könnte das das mit dem url pfad funktioniert...

ah

Verfasst: 27.02.2003 17:04
von mario8
hallo!

kann ich es also so wie ganz oben angeführt in meine portal.php einfügen?

wenn ich das mache bekomme ich auf jeden fall eine menge fehlermeldungen!

ich muss doch diese beiden sachen die am anfang <?php und am ende ?> der seite stehen weglassen oder?


danke im voraus
grüsse
mario

Verfasst: 28.02.2003 12:22
von Acid
saerdnaer hat geschrieben:wobei ich mit nicht vorstellen könnte das das mit dem url pfad funktioniert...
..meinereiner auch ned, höchstens mit´m absoluten Pfad.

@mario
Da das obige php ist, sollten <?php und ?> nicht gelöscht werden.

Verfasst: 01.03.2003 10:53
von mario8
@acid

wenn ich die oben angeführten code in eine bereits bestehende datei z.b. portal.php einfüge habe ich ja diese zwei <?php und ?> sowieso am anfang und am ende.

kommt es hierdurch dann nicht zu fehlermeldungen???

grüsse
mario

Verfasst: 01.03.2003 10:57
von Acid
aso ..nee dann könntest beides löschen.

Verfasst: 01.03.2003 11:04
von mario8
muss ich sonnst irgendwas beachten wenn ich den code in meine portal.php efügen möchte?

grüsse
mario