|
|
|
|
|
|
| |
I was recently asked how to add a listing (such as the one on the right) of recent PHPBB posts to a website...here it is
As always, its easily customizable to suit your needs of what you want to display (in this case its just the subject as a link)
Regards
Bastien
| <?
$sql = '';
$limit = 10; //default number of posts to show change it to show more or fewer recent posts
$path = 'phpbb2'; //default path to the phpbb folder in your site
//this assumes it is one deeper that this page
//change it to match your site's layout
// Connect to your database: Fill in the elements below
$db = mysql_connect("localhost", "user", "pass") or die("Unable to connect to mysql.".mysql_error());
//phpbb is the default phpbb db name, change it if it is not correct
mysql_select_db ("phpbb",$db) or die("Unable to select database".mysql_error());
// Select the info you need from your table.
$sql = "SELECT a. * , b.post_time
FROM phpbb_posts_text a, phpbb_posts b
WHERE a.post_id = b.post_id
ORDER BY post_time DESC
LIMIT $limit";
$result=mysql_query($sql) or die("Unable to select news.".mysql_error());
while($row = mysql_fetch_array($result)){
// echo out entry here
// column_name is the name of the column in the database
echo "Subject: <a href=\"$path/viewtopic.php?p=".$row['post_id']."#".$row['post_id']."\">".$row["post_subject"]."</a><br>";
}
// Now disconnect from the database.
mysql_close($db);
?> | | |
|
| icq status checker online offline disabled unknown Categories : PHP, Miscellaneous | | | This is a simple PHP3 script to send an instant msg to the webmaster (only for Windows NT). Categories : PHP, Misc, Miscellaneous | | | What does "PHP" stand for? Categories : Miscellaneous, PHP | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | Invision Forums Latest Threads list Categories : PHP, Miscellaneous, Databases, MySQL | | | How to display any array in several rows and columns of a table. Not just
in one column or in alternate rows. This example shows a nice color table
generated with PHP, but can be used with any array values(e.g. Database) Categories : Arrays, PHP, Miscellaneous, Beginner Guides, Graphics | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | PHP Script to find url links in a page Categories : PHP, URLs, Regexps, Arrays | | | Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate. Categories : Authentication, PHP | | | very simple ftp class Categories : PHP, PHP Classes, FTP | | | PHP Paypal IPN Integration Class v1.0.0 Categories : PHP, PHP Classes, Payment Gateways | | | Function to remember password Categories : PHP, Authentication, Personalization and Membership | | | Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality. Categories : PHP, GD image library, Graphics | | | readline -- Reads a line Categories : PHP, PHP Functions, Readline | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | |
|
|
|