Guest Posted November 20, 2019 Share Posted November 20, 2019 (edited) # 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 November 20, 2019 by Guest Quote Link to comment https://forums.phpfreaks.com/topic/309552-to-display-logged-in-users-comments/ Share on other sites More sharing options...
benanamen Posted November 20, 2019 Share Posted November 20, 2019 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. Quote Link to comment https://forums.phpfreaks.com/topic/309552-to-display-logged-in-users-comments/#findComment-1571725 Share on other sites More sharing options...
maxxd Posted November 21, 2019 Share Posted November 21, 2019 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. Quote Link to comment https://forums.phpfreaks.com/topic/309552-to-display-logged-in-users-comments/#findComment-1571757 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.