Help - Search - Members - Calendar
Full Version: A little php code help?
4peeps.com Forums > General Hardware/Software > Programmers Corner
bull
I am trying to make the IPDL latest discussions only pull from selected forums. I have it able to pull from one forum with this code:

CODE
$latest_forum = 1;
$DB->query("SELECT tid, title, posts, starter_id as member_id, starter_name as member_name, start_date as post_date, views FROM ibf_topics WHERE forum_id={$latest_forum} AND state!='closed' AND approved=1 AND (moved_to IS NULL or moved_to='') $qe ORDER BY start_date DESC LIMIT 0,$limit");


Is there a way to change the $latest_forum = 1; to parse more forums?
AceHigh
Try repeating the code for every forum you want to feed, replacing "1" with the appropriate forum ID.

$latest_forum = 1;
$DB->query("SELECT tid, title, posts, starter_id as member_id, starter_name as member_name, start_date as post_date, views FROM ibf_topics WHERE forum_id={$latest_forum} AND state!='closed' AND approved=1 AND (moved_to IS NULL or moved_to='') $qe ORDER BY start_date DESC LIMIT 0,$limit");

$latest_forum = 2;
$DB->query("SELECT tid, title, posts, starter_id as member_id, starter_name as member_name, start_date as post_date, views FROM ibf_topics WHERE forum_id={$latest_forum} AND state!='closed' AND approved=1 AND (moved_to IS NULL or moved_to='') $qe ORDER BY start_date DESC LIMIT 0,$limit");

$latest_forum = 3;
$DB->query("SELECT tid, title, posts, starter_id as member_id, starter_name as member_name, start_date as post_date, views FROM ibf_topics WHERE forum_id={$latest_forum} AND state!='closed' AND approved=1 AND (moved_to IS NULL or moved_to='') $qe ORDER BY start_date DESC LIMIT 0,$limit");

etc
Mandark
how about doing it in a loop so you don't repeat code needlessly? Make the ID a variable in an array or something....

I am GLAD ace is not a developer... ROFL JJ
AceHigh
He got it working, and YES!!!!!!!!! I'm GLAD I'm not a developer. I HATE IT!!!!!!!!!!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.