Jump to content

Getting username of last inserted record


AdRock

Recommended Posts

I am making a small message board with 3 tables, boards, topics and messages

 

I can display each of the board titles, the number of topics in each board and the total number of messages.

 

What i don't know how to do is get the username of the person who made the last post in that board and what the topic was and date (much like on the forum index on here)

 

I thought about doing a seperate query using a mysql_insert_id() of the last record but don't know how i'd put that in my table as the table is being displayed in the main query.

 

Is there a way I could do what i want with the query i got already?

 

// Perform a query getting back a MySQLResult object
$result = $db->query($sql);

$err = $result->size();

// Include the header html
require_once("header.inc.php");

if($err !=0) {
echo '<table id="boards"><tr><th colspan="3">Sound Off Discussion Boards</th></tr>';
while ($row = $result->fetch()) {
	$boardname = ucwords($row['boardname']);

	echo "<tr><td><a href=''>{$boardname}</a><br />some gumf about the baord</td>";
	echo "<td>{$row["message"]} Posts<br />{$row["topics"]} Topics</td>";
	echo" <td></td></tr>";
}
echo '</table>';				
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.