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>';				
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.