如何获取status_content列的数据?

时间:2016-08-11 03:14:00

标签: php mysql

我正在尝试建立一个状态/帖子。我的表(post)id,user_id,status_time和status_content中有4个字段。我想获取我的status_content只有1个user_id的数据,有人可以帮助我吗?

例如:

我有3个用户

用户1 =发布3次

用户2 =发布2次

用户3 =发布5次

我怎样才能获得用户3发布的所有数据?

抱歉我的英文。

将数据发送到我的数据库的代码

profile.php

if(isset($_POST['status_content'])){
        $status_content = $_POST['status_content'];
        if(!empty($_POST['status_content'])){
        add_status($_SESSION['accts_id'], $status_time, $status_content);
    }
}

core.php中

function add_status($accts_id, $status_time, $status_content){
$sql = "INSERT INTO `post` (user_id, status_time, status_content) VALUES ('$accts_id', '$status_time', '$status_content')";
mysql_query($sql);}

1 个答案:

答案 0 :(得分:0)

您可以按如下方式使用

特别为用户3获取数据

select status_content from post where user_id = '3'

获取任何用户的数据

select status_content from post where user_id = $_SESSION['accts_id'];

[<强>已更新