Jump to content

Archived

This topic is now archived and is closed to further replies.

legohead6

Showing post from a phpbb forum elsewhere

Recommended Posts

ok..on my homepage i want it to show the last 5 post from the phpbb forum(easy) the twist is i want it to be the last 5 posts from the announcements forum only(fourm_id=4) heres the code i have that displays the last 5 post...

[code]<html>
<body>

<?
$host = "localhost";
$user = "--";
$pass = "--";
$db = "phpforum";


$connection = mysql_connect($host,$user,$pass) or die ("Unable to
connect!");

mysql_select_db($db) or die ("Unable to select database!");

$query = "SELECT * FROM posts_text ORDER BY post_id DESC LIMIT 6";
$query2 = "SELECT * FROM post_subject ORDER BY post_id DESC LIMIT 6";
$result = mysql_query($query);
$result2 = mysql_query($query2);
$i=0;
$t=5;
if ($result && $result2) {
echo "Recent Forum Post<br><br>";
}
while($i < $t){
$first=mysql_result($result,$i,"post_text");
$sub=mysql_result($result,$i,"post_subject");

echo "Subject: <b>$sub</b><br>Message: <b>$first</b> <br><br>";
$i++;
}
?>
</body>[/code]

and here it is(with what i think is a good start toward my goal)

[code]<html>
<body>

<?
$host = "localhost";
$user = "--";
$pass = "--";
$db = "phpforum";


$connection = mysql_connect($host,$user,$pass) or die ("Unable to
connect!");

mysql_select_db($db) or die ("Unable to select database!");

$query = "SELECT * FROM posts_text ORDER BY post_id DESC LIMIT 6";
$query2 = "SELECT * FROM post_subject ORDER BY post_id DESC LIMIT 6";
$query3 = "SELECT forum_id FROM forums ORDER BY post_id DESC LIMIT 6";
$result = mysql_query($query);
$result2 = mysql_query($query2);
$result3 = mysql_query($query3);
$w=0;
$t=5;
$i= "forum_id";
if ($result && $result2 && $result3) {
echo "Recent Forum Post<br><br>";
}
while($w < $t){
$first=mysql_result($result,$w,"post_text");
$sub=mysql_result($result,$w,"post_subject");

echo "Subject: <b>$sub</b><br>Message: <b>$first</b> <br><br>";
$w++;
}
?>
<p>
</body>[/code]

please if possible dont give me aton of advanced stuff(because im trying to learn as i go..still quiet new to php)
Thanks
Matt

Share this post


Link to post
Share on other sites
[!--quoteo(post=361837:date=Apr 4 2006, 11:04 PM:name=cunoodle2)--][div class=\'quotetop\']QUOTE(cunoodle2 @ Apr 4 2006, 11:04 PM) [snapback]361837[/snapback][/div][div class=\'quotemain\'][!--quotec--]
In your query can't you just add this..

WHERE `fourm_id`='4'

Let me know
[/quote]

umm..this comes up for every one!

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in updates.php on line 26

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in updates.php on line 27
Subject:
Message:

lines 26 and 27 are here

$first=mysql_result($result,"post_text");
$sub=mysql_result($result2,"post_subject");

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.