Stargate05 Posted July 8, 2010 Share Posted July 8, 2010 Hey guys, Using this code, does anyone see how I could add the user name of the person who made the post and the time and date it was posted at? This code already shows the title of the topic and gives a link to the topic in the forum. <?php $connection = mysql_connect("localhost", "imissth1_phpb4", "[1E199M[1y8W") or die("Service Temporarily Unavailable"); $db = mysql_select_db("imissth1_phpb4",$connection) or die("Service temporairly unavailable"); $sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,10"; $result = mysql_query($sql) or die("Service temporairly unavailable"); for($x=1;$x<=10;$x++){ $row = mysql_fetch_array($result); echo "<a href = \"http://www.codenamekingdom.com/forum/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\" target = \"_blank\">$row[topic_title]</a><br><br>"; } ?> Don't know how many of you use MySql but thanks in advance guys! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 8, 2010 Share Posted July 8, 2010 You'd need to know what the database field names are that store that information, the just retrieve it and echo it with the rest of the info. Quote Link to comment Share on other sites More sharing options...
Stargate05 Posted July 8, 2010 Author Share Posted July 8, 2010 Alright thanks, I'm not really used to the php coding I don't suppose when you have some time you might be able to show me what the echo my look like coded? I can definitely find the field names. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 8, 2010 Share Posted July 8, 2010 There's only one echo() in the code above: echo "<a href = \"http://www.codenamekingdom.com/forum/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\" target = \"_blank\">$row[topic_title]</a><br><br>"; If the syntax in that line doesn't make sense to you, just post the field names, and I'm sure someone (if not me) will be by shortly to help. Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted July 8, 2010 Share Posted July 8, 2010 use this code to echo it <?php $connection = mysql_connect("localhost", "imissth1_phpb4", "[1E199M[1y8W") or die("Service Temporarily Unavailable"); $db = mysql_select_db("imissth1_phpb4",$connection) or die("Service temporairly unavailable"); $sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,10"; $result = mysql_query($sql) or die("Service temporairly unavailable"); for($x=1;$x<=10;$x++){ $row = mysql_fetch_array($result); print_r($row);// this will print everything in the array including the array name echo "<a href = \"http://www.codenamekingdom.com/forum/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\" target = \"_blank\">$row[topic_title]</a><br><br>"; } ?> Quote Link to comment Share on other sites More sharing options...
Stargate05 Posted July 8, 2010 Author Share Posted July 8, 2010 Thanks BillyBoB but all I got was a huge amount of seemingly random data ;P Pikachu, I would really appreciate it if you could, here are the field names for the username and time posted: topic_last_poster_name (username to last post in topic) and topic_last_post_time (last time topic was posted in) I was hoping to see something like this: TOPIC TITLE Last Posted in by: topic_last_poster_name On: topic_last_post_time Only thing is I dont understand the time... in the database for example, its just a random number... ie. 1278533748 How would you turn that into an actual date? Thanks a lot for all the help! Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted July 8, 2010 Share Posted July 8, 2010 when you look into the database can you find the column topic_last_post_time and see what type it is. if the date is stored with php timestamp values then its type would be string... your end code would look like <?php $connection = mysql_connect("localhost", "imissth1_phpb4", "[1E199M[1y8W") or die("Service Temporarily Unavailable"); $db = mysql_select_db("imissth1_phpb4",$connection) or die("Service temporairly unavailable"); $sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,10"; $result = mysql_query($sql) or die("Service temporairly unavailable"); for($x=1;$x<=10;$x++){ $row = mysql_fetch_array($result); echo "<a href = \"http://www.codenamekingdom.com/forum/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\" target = \"_blank\">$row[topic_title]</a><br>Last Posted in by: $row[topic_last_poster_name]<br>On: $row[topic_last_post_time]<br><br>";//you may need to convert the time into a workable string... } ?> Quote Link to comment Share on other sites More sharing options...
Stargate05 Posted July 8, 2010 Author Share Posted July 8, 2010 Thanks for the code BillyBob! Works great except you were right the time is still messed up. Not quite sure what you mean by the "type" though... if you want an example of the value under the topic_last_post_time it would be something like: 1278533748 The only other info on that category I can find is: Showing rows 0 - 2 (3 total, Query took 0.0004 sec) [topic_time: 1278533748 - 1278536261] SELECT * FROM `phpbb_topics` ORDER BY `phpbb_topics`.`topic_time` ASC LIMIT 0 , 30 Does that help or should I be looking for something else? Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted July 8, 2010 Share Posted July 8, 2010 i would say that it is a php timestamp. the solution to that would be <?php $connection = mysql_connect("localhost", "imissth1_phpb4", "[1E199M[1y8W") or die("Service Temporarily Unavailable"); $db = mysql_select_db("imissth1_phpb4",$connection) or die("Service temporairly unavailable"); $sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,10"; $result = mysql_query($sql) or die("Service temporairly unavailable"); for($x=1;$x<=10;$x++){ $row = mysql_fetch_array($result); echo "<a href = \"http://www.codenamekingdom.com/forum/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\" target = \"_blank\">$row[topic_title]</a><br>Last Posted in by: $row[topic_last_poster_name]<br>On: ".date("d-m-y h:i:s", $row['topic_last_post_time'])."<br><br>"; } ?> Quote Link to comment Share on other sites More sharing options...
Stargate05 Posted July 8, 2010 Author Share Posted July 8, 2010 Works AMAZINGLY! Thanks very much BillyBoB!! 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.