我有以下代码在论坛讨论中显示帖子。
我希望发布反应的人看到两个按钮:
我似乎找不到将用户会话连接到forumberichten表中的userid的方法。有没有人可以帮我这个?我已经尝试了很多东西,但我一直在所有帖子上都有按钮。
<?php
if (isset($_REQUEST['id'])){
$id = preg_replace('#[^a-z0-9]#i', '', $_GET['id']);
}
$user = $_SESSION['SESS_USERID'];
if (isset($_REQUEST['user'])){
$user = preg_replace('#[^a-z0-9]#i', '', $_GET['user']);
}
$sql="SELECT forumberichten.bericht_id,forumberichten.discussieid,forumberichten.userid,forumberichten.omschrijving,forumberichten.datum, forumberichten.active,users.userid,users.username,users.userimage FROM forumberichten,users WHERE forumberichten.userid=users.userid AND forumberichten.active='yes' AND forumberichten.discussieid='".$id."' ORDER BY discussieid DESC";
$result = $conn->query($sql);
if ($result->num_rows >=1) {
while($row = $result->fetch_assoc()) {
echo "
<br><table width='450' border='0'>
<tr><td bgcolor='#1E1E1E'> </td>
<td colspan='5' bgcolor='#1E1E1E'><a href='user.php? id=" . $row['userid'] . "'</a> ".$row["username"]."</td>
<td> </td></tr>
<tr><td bgcolor='#1E1E1E'> </td>
<td colspan='5' bgcolor='#1E1E1E'>
";
if ($row["userimage"] == '') {
echo "
<a href='user.php? id=" . $row['userid'] . "'</a>
<img src='Images/users/nopicture.png' alt='nopicture' class='user-imagelarge' title='".$row['username']."''>
</a>
";
} else {
echo "
<a href='user.php? id=" . $row['userid'] . "'</a>
<img src='Images/users/".$row['userimage']."' class='user-imagelarge' title='".$row['username']."''>
</a>
";
}
echo "
</td>
<td> </td></tr>
<tr><td bgcolor='#1E1E1E'> </td>
<td colspan='5' bgcolor='#1E1E1E'>".$row['omschrijving']."</td>
<td> </td></tr>
<tr><td bgcolor='#1E1E1E'> </td>
<td bgcolor='#1E1E1E'>
";
echo date("d-m-y H:i",strtotime($row["datum"]));"</td>";
// HERE I DON'T KNOW WHAT TO DO SO ONLY THE POSTER OF THIS MESSAGE CAN SEE THE FOLLOWING BUTTONS:
echo "
<td bgcolor='#1E1E1E'><a href='forumberichtbewerk.php? id=" . $row['bericht_id'] . "' target='_blank'>
<input type='image' src='Images/Icons/penorange.png' width='15' height='15'></a></td>
<td bgcolor='#1E1E1E'><a href='forumberichtdelete.php? id=" . $row['bericht_id'] . "'><input type='image' class='backgroundgreyfotoos' src='Images/Icons/crossorangebutton.png' width='15' height='15' border='0' ></a></td>
<td bgcolor='#1E1E1E'></td>
<td bgcolor='#1E1E1E'></td>
<td> </td></tr>
<tr><td bgcolor='#1E1E1E'> </td>
<td colspan='5' bgcolor='#1E1E1E'><img src='Images/lijntransparant.png' width='570' height='2'></td>
<td><img src='Images/lijntransparant.png' width='35' height='2'></td></tr>
</table>
";
}
}
?>