Another php code question
2 posts
• Page 1 of 1
Another php code question
php question for ya.
I have this line in phpbb:
$topic_sql = "SELECT t.topic_id, t.topic_title, t.topic_replies, t.topic_views, u.username, u.user_id FROM phpbb_topics t, phpbb_users u WHERE t.forum_id = $forum_id AND t.topic_poster = u.user_id ORDER BY topic_last_post_id DESC LIMIT $limit";
And all I want to do is include this variable: f.forum_name
Problem is that is comes out of the phpbb forums table "f". How can I make the above line pull that variable so I can get the forum's name?
Thanks for any help you can provide on that snippet.
"Greatness is not a function of circumstance. Greatness, it turns out, is largely a matter of conscious choice, and discipline." - Jim Collins
- kanaloa
- President
- Posts: 11795
- Joined: Sun Mar 10, 2002 1:18 am
- Location: HI & SC
- Real Name: John Derrick
What you have to do is setup an alias name for that table in your SQL statement. I am guessing "f" stands for forum so it would be something like this
$topic_sql = "SELECT t.topic_id, t.topic_title, t.topic_replies, t.topic_views, u.username, u.user_id, f.forum_name FROM phpbb_topics t, phpbb_users u, phpbb_forums f WHERE t.forum_id = $forum_id AND t.topic_poster = u.user_id ORDER BY topic_last_post_id DESC LIMIT $limit";
You also need to setup a WHERE clause which would be, I believe in the topics table it is still labeled as forum_id. So you would also need to add to the WHERE clause
$topic_sql = "SELECT t.topic_id, t.topic_title, t.topic_replies, t.topic_views, u.username, u.user_id, f.forum_name FROM phpbb_topics t, phpbb_users u, phpbb_forums f WHERE t.forum_id = $forum_id AND t.topic_poster = u.user_id AND f.forum_id = t.forum_id ORDER BY topic_last_post_id DESC LIMIT $limit";
HTH
- jbullard
- VP - Software
- Posts: 3653
- Joined: Sun Jun 06, 2004 10:17 pm
- Location: Utah
- Real Name: Jason Bullard
2 posts
• Page 1 of 1
Return to HTML, CSS, and Scripts
Who is online
Users browsing this forum: No registered users and 5 guests