Hi, I have written the following code to display posts from my forum in plain text, I'm hoping to end up with: Post #, Subject, Message, and Username.
Currently, the script displays all this fine, but the username stored in the phpbb3_posts table is just the poster_id, a number which corresponds to user_id in the phpbb3_users table. So my question is, how do I make the script find the user_id which is equal to the poster_id of the post, and then find the username in the same row as the user_id it just found?
<?php
$username="xxxxx";
$password="xxxxx";
$database="phpbb3";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM phpbb3_posts";
$result=mysql_query($query);
$num=mysql_numrows($result);
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num) {
$field1=mysql_result($result,$i,"post_id");
$field2=mysql_result($result,$i,"post_subject");
$field3=mysql_result($result,$i,"post_text");
$field4=mysql_result($result,$i,"poster_id");
$usernm=mysql_query("SELECT user_id, username FROM phpbb3_users WHERE
echo "<b>$field1<br>$field2</b><br>$field3<br>$field4<hr><br>";
$i++;
}
mysql_close();
?>
http://123.255.41.116/test.php --> This is the current result of the script.