legohead6 Posted April 5, 2006 Share Posted April 5, 2006 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 toconnect!");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 toconnect!");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)ThanksMatt Quote Link to comment Share on other sites More sharing options...
cunoodle2 Posted April 5, 2006 Share Posted April 5, 2006 In your query can't you just add this..WHERE `fourm_id`='4'Let me know Quote Link to comment Share on other sites More sharing options...
legohead6 Posted April 5, 2006 Author Share Posted April 5, 2006 [!--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 26Warning: mysql_result(): supplied argument is not a valid MySQL result resource in updates.php on line 27Subject: Message: lines 26 and 27 are here$first=mysql_result($result,"post_text");$sub=mysql_result($result2,"post_subject"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.