adam87 Posted March 20, 2009 Share Posted March 20, 2009 Hey this is my first post on the forums. I've been studying PHP and mySQL for about a year now and currently working on a message board. I've got it working so that the user can only post if they are logged in. So basically I want it to check if the message author is the same as the person logged in and if so to show a edit button below the post. Below is the code I'm doing for the if statement for it to show the edit: $user_check = mysql_query("SELECT user_name FROM reviews"); if ($_SESSION['user'] == $user_check ) { echo "<tr>"; echo "<td> Edit </td>"; echo "</tr>"; } else { echo "<tr>"; echo "<td> Shit </td>"; echo "</tr>"; I've written Edit for it to just appear once i got that working I will then modify it to a link etc Link to comment https://forums.phpfreaks.com/topic/150381-edit-post/ Share on other sites More sharing options...
Mchl Posted March 20, 2009 Share Posted March 20, 2009 Welcome to the forums. For future reference: it helps if you actually ask a question. In your code you using mysql_query in a wrong way. It returns a result resource, not actual data. See mysql_fetch_array Link to comment https://forums.phpfreaks.com/topic/150381-edit-post/#findComment-789736 Share on other sites More sharing options...
adam87 Posted March 20, 2009 Author Share Posted March 20, 2009 Hey I just realized that.......... basically the question I'm asking is what would I put within the if statement for it to check the session user and the poster of that specific review. Link to comment https://forums.phpfreaks.com/topic/150381-edit-post/#findComment-789743 Share on other sites More sharing options...
Mchl Posted March 20, 2009 Share Posted March 20, 2009 First, you should make sure the query gets the name of poster from database. Then just comapare it with name stored in session. Better approach would be to compare unique IDs. Link to comment https://forums.phpfreaks.com/topic/150381-edit-post/#findComment-789745 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.