View Full Version : Query to phpbb2 db
06-07-2004, 07:25 PM
This is a simple question. Specifically, how would I query a phpbb2 database to print the most recent post in an external php page?
06-08-2004, 02:10 AM
This is the code I have so far:
$db = mysql_connect("localhost", "root");
$result = mysql_query("SELECT * FROM ?????",$db);
printf("Author: %s<br>\n", mysql_result($result,0,"????"));
printf("Title: %s<br>\n", mysql_result($result,0,"????"));
printf("Date: %s<br>\n", mysql_result($result,0,"????"));
I am not sure how to print the author, date and title as I do not know what they called. The phpbb2 board was installed by another man.
06-08-2004, 10:27 AM
ok here is what ive found concerning this:
2 tables: phpbb_posts and phpbb_posts_text. Altho the prefix is set at installation, but that is the default. I think you can get the most recent post by just getting the highest post_id(which is in both tables).
Title is in phpbb_posts_text as column name post_subject.
Date is a timestamp(think its not a mysql form, already unix form) in phpbb_posts, column name post_time.
The authors user id is in phpbb_posts as poster_id. You can find out the username by using table phpbb_users and checking the user_id column. The username is stored in username in phpbb_users.
Hope all this helps!!
06-08-2004, 11:02 AM
My code for this:
$query = "SELECT u.username, t.post_subject, p.post_time FROM phpbb_users u, phpbb_posts p, phpbb_posts_text t WHERE MAX(p.post_id) AND p.poster_id = u.user_id ;
Then use date() to convert the timestamp etc etc and format as required.
You could also search for the maximum timestamp in p.post_time, this would also give the latest post.
I'm not great at SQL so some of that query might be wrong, especially perhaps the MAX part...but everything up to the WHERE is correct at least, for def :p
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.