I posted this on PHP help too, not sure where it should go. At second thoughts it probobly suits MySQL better...
When I use the following code it doesn't error, but instead brings back something that I don't udnerstand.
The code is meant to pull the first post of each topic located in the news board of my phpBB forum.
phpBB uses 2 tables to store its posts. I made this code originally to pull code of SMF forums, and it worked, but SMF only used one table.
$result = mysql_query("SELECT Distinct post_id FROM phpbb_posts where forum_id='1' order by post_id desc")
or die(mysql_error());
echo "<table boarder='0'>";
echo "<tr><th>Subject</th><th>Message</th></tr>";
while($row = mysql_fetch_array($result)) {
$result1 = mysql_query("Select * from phpbb_posts_text where post_id=".$result." order by post_id asc limit 1")
or die(mysql_error());
while($row = mysql_fetch_array( $result1 )) {
echo "<tr><td>";
echo $row['post_subject'];
echo "</td><td>";
echo $row['post_text'];
echo "</td></tr>";
}
}
echo "</table>";
echo $result1;
I put $result1 at the end to see what it returns, it should return nubers only, sinse only numbers exist in that table. However it replies with 'Resource id#4'.
It currently does reveal the newest post of the newest topic twice in the table, then stops.