ashton Posted July 28, 2006 Share Posted July 28, 2006 Alright I made a game, And the forums are self programmed meaning there not PHPBB forums, there just forums programmed with php, I have seen on websites how on the home page they display new posts, most recent etc. could anyone show me how to set one of those up? Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/ Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 easy, do a select statement, have something in the database to differentiate, and do some calls to the db, just limit them so they don't overwhelm the visitor, like 20-30 per page. Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65150 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 Hmm easier said that done, do you think you could help me out please, like how to code this etc. If you have aim: Ashtonhy or Over Email: ashtonhy@gmail.com ?? Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65152 Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 well for most recent, you would probably want to have the date logged when they post, sort by date, like have a field calledpostdatehave it put a time stamp there whenever they postthen on the homepagehave$select = "SELECT * FROM tablename SORT BY postdate LIMIT 4;";$query = mysql_query($select);while ($row = mysql_fetch_array) {// whatever to display$controller = true; // or whatever variable}if ($controller != true) {echo "There are no recent entries";}you probably wouldn't need the message if it's a forum though because there will always be recent entries, just the last 3 posted entries. Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65153 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 Alright that looks good, but another question to display time, Because I have it displaying date, I would add a new field in the forum Table, but then how would I go about scripting that? Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65155 Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 table field name could be timeentry$variable = time();to display itit's the same thing$select = "SELECT * FROM tablename SORT BY postdate, timeentry LIMIT 4;";I don't remember what goes in between those and I don't have time to check it's either postdate AND timeentrypostdate OR time entrypostdate, time entryit's one of the three. Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65160 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 $select = "SELECT * FROM tablename SORT BY postdate LIMIT 4;";$query = mysql_query($select);while ($row = mysql_fetch_array) {// whatever to display$controller = true; // or whatever variable}if ($controller != true) {echo "There are no recent entries";}Alright were it says "what ever to display" what exactly would go there? Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65161 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 Oh and btw Im liking this site allready, thank you, business man your very helpfull! ;D Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65163 Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 [code]It depends on how you wanted to display it, with tables it would be like<?phpecho "<table>";while ($row = mysql_fetch_array) {echo "<tr><td>$variable</td></tr>";$controller = true; // or whatever variable}echo "</table>";// tables outside of while, or it redoes table every circle through?>[/code]Just put the data in a formatted table, I can't do it for you, ebcause I don't have time and because I don't know how many fields you have, or you can use lists[code]<?phpecho "<ul>" or echo "<ol>" // more of ulwhile ($row = mysql_fetch_array) {echo "<li>{variablename}</li>";echo "<li>{varieblename2}</li>";$controller = true; // or whatever variable}echo "<ul" or echo "<ol>" // more of ul[/code]of course each call you make to the db variable you have to use the variable you used to access it, in this case it would be$row['variablename']or $row['variablenamer']when extrapolating they teach you to leave off the ' ' like$row[variablename]$row[variablename2] Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65168 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 Parse error: parse error, unexpected '}' in /home/spxxxrw/public_html/mf/recentforum.php on line 9<?php$dbh=mysql_connect ("localhost", "spxxxrw_Axxxxn", "asxxxxxxx96") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ("spyderw_dk");$select = mysql_query("SELECT author,newpostdate,title, FROM spxxxxxw_forum ORDER BY `newpostdate` DESC LIMIT 3");$total=1;while($row = mysql_fetch_array($select))}if(isset($_GET['display'])) echo $recentforum;?>Any idea whats wronge with it?"xxx" added for secur. Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65178 Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 [code]<?php$dbh=mysql_connect ("localhost", "spxxxrw_Axxxxn", "asxxxxxxx96") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ("spyderw_dk");$select = mysql_query("SELECT author,newpostdate,title, FROM spxxxxxw_forum ORDER BY `newpostdate` DESC LIMIT 3");$total=1;while($row = mysql_fetch_array($select)) {}if(isset($_GET['display'])) echo $recentforum;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65180 Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 [code]if(isset($_GET['display'])) echo $recentforum;[/code]That is not good practice, I was shown this before, someone corrected if not I would have made a grave mistakeit's always[code]<?phpif (isset($get['display'])) {echo $recentforum; // even here I like echo "{$recentforum}"; just depends on preference}// or if (isset($get['display'])) {echo $recentforum;}// I prefer the top?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65183 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 I put in what you gave me and got this:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/spyderw/public_html/mf/recentforum.php on line 7<?php$dbh=mysql_connect ("localhost", "spyxxxton", "ashtxxx596") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ("spydxxxk");$select = mysql_query("SELECT author,newpostdate,title, FROM spydexxxum ORDER BY `newpostdate` DESC LIMIT 3");$total=1;while($row = mysql_fetch_array($select)) {}if(isset($_GET['display'])) echo $recentforum;?> Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65184 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 ooh so your uptop post is prob my problem? Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65187 Share on other sites More sharing options...
ashton Posted July 28, 2006 Author Share Posted July 28, 2006 Parse error: parse error, unexpected $ in /home/spyderw/public_html/mf/recentforum.php on line 11[code]<?php$dbh=mysql_connect ("localhost", "spyderw_Ashton", "ashton2004596") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ("spyderw_dk");$select = mysql_query("SELECT author,newpostdate,title, FROM spyderw_forum ORDER BY `newpostdate` DESC LIMIT 3");$total=1;while($row = mysql_fetch_array($select)) {}if (isset($get['display'])) {echo $recentforum; // even here I like echo "{$recentforum}"; ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65191 Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 [code]<?php$dbh=mysql_connect ("localhost", "spyderw_Ashton", "ashton2004596") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ("spyderw_dk");$select = mysql_query("SELECT author,newpostdate,title, FROM spyderw_forum ORDER BY `newpostdate` DESC LIMIT 3");$total=1;while($row = mysql_fetch_array($select)) {}if (isset($get['display'])) {echo $recentforum; // even here I like echo "{$recentforum}"; }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65192 Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 [code]<?php$dbh=mysql_connect ("localhost", "spyderw_Ashton", "ashton2004596") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ("spyderw_dk");$select = mysql_query("SELECT author,newpostdate,title, FROM spyderw_forum ORDER BY `newpostdate` DESC LIMIT 3");$total=1;while($row = mysql_fetch_array($select)) {}if (isset($get['display'])) {echo $recentforum; // even here I like echo "{$recentforum}"; }?>[/code]The code here doens't make sense to me though, your while statement is doing absolutely nothing. Quote Link to comment https://forums.phpfreaks.com/topic/15887-putting-the-new-forum-posts-on-the-home-page/#findComment-65193 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.