Map username to latest postings script (General)
With my limited php skills I'm creating a simple script that shows the latest postings from my MLF installation along with post date and author. Getting the post, date, topic ID etc. from mlf_entries turned out easy, but getting the author was more challenging since the username is stored in mlf_userdata. I suppose I have to use JOIN to map the specific posting in mlf_entries to te correct user_id from mlf_userdata?
Could anyone explain to me how this query should look?
Example of what I want to achieve (except for the Username I have everything in place):
- Latest forum thread name
by Username on 6 December 2015
- Second latest forum thread name
by Username on 6 December 2015
I know there is a function for this which is supplied by MLF that does what I want to achieve, but I want to avoid having to go via RSS.
What I have so far:
<?php $query = "SELECT UNIX_TIMESTAMP(time), subject, category, tid, views, last_reply, text, last_reply, user_id FROM mlf2_entries GROUP BY tid ORDER BY last_reply DESC LIMIT 0, 5"; $result = mysql_query($query, $conn) or die("Query failed : " . mysql_error()); echo "<ul>"; while($row = mysql_fetch_array( $result )) { $topic = $row["subject"]; $tid = $row["tid"]; $category = $row["category"]; $user_id = $row["user_id"]; $last_reply = $row["last_reply"]; echo "<li><a href= \"/index.php?mode=thread&id=".$tid."\">$topic</a></li>"; } echo "</ul>"; mysql_free_result($result); mysql_close($conn); ?>