PHP-如何区分同一用户的帖子?

时间:2018-08-06 13:37:58

标签: php mysql

我正在建立一个发布系统;我可以显示所有已创建帖子的列表,单击该列表可以通过使用$ _SERVER ['QUERY_STRING']将您带到显示正确帖子及其信息的新页面(如果用户仅创建了一个帖子)。事情是我用来区分帖子的字符串,是帖子创建者的用户名,创建时以“ post_uid”的形式存储在帖子中,其中== user_uid。因此,现在如果用户创建了多个帖子,则在单击时在锚点列表页面上显示的每个帖子只会从用户创建的第一个帖子中拉出其变量,而不是新的。任何有关如何解决此问题的建议将不胜感激。

这是我要单击的帖子列表的代码:

$sql="SELECT * FROM posts ORDER BY post_id";
$result=mysqli_query($conn,$sql);

$i = 0;
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC)) {
       if($i==15) break;
        $post_title = $row['post_title'];
        $post_uid = $row['post_uid'];
        $updated = $row['post_updated'];
        echo '<br><h1><a href="./post-select-brief.php?'.$post_uid.'">'. 
        $post_title .', price: '. $row['post_price'] .'</a></h1></br>';
        $i++;


}

这是我完整帖子的代码:

$result1 = mysqli_query($conn, "SELECT * FROM posts WHERE post_uid 
='".$_SERVER['QUERY_STRING']."'");

$row2 = mysqli_fetch_array($result1);

$uid = ucfirst($row2['post_uid']); 

$rating = $row2['rating'];

stating varibales etc etc....

感谢您提供的任何帮助!

0 个答案:

没有答案