Jump to content
Guest

To display logged in user's comments

Recommended Posts

Guest


# Display body section, retrieving from 'forum' database table.
$q = "SELECT * FROM forum" ;
$r = mysqli_query( $dbc, $q ) ;
if ( mysqli_num_rows( $r ) > 0 )
{
  echo '<table><tr><th>Posted By</th><th>Subject</th><th id="msg">Message</th></tr>';
  while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC ))
  {
    echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. $row['post_date'].'</td>
    <td>' . $row['subject'] . '</td><td>' . $row['message'] . '</td> </tr>';
  }
  echo '</table>' ;
}
else { echo '<p>There are currently no messages.</p>' ; }

Hi,

I tried this before. I wanted to get the user's messages only. This is code is meant for any general display of logged in users who post to the forum table.

I think this will need some sort of session id.

Edited by Guest

Share this post


Link to post
Share on other sites
3 hours ago, tryingphp said:

I think this will need some sort of session id.

You will need a session id and a WHERE clause in your query.

Share this post


Link to post
Share on other sites

Or $_POST or $_GET as well as the WHERE clause; the important part here is that you're gonna need a WHERE clause in your SQL statement.

Share this post


Link to post
Share on other sites

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.