2017-08-06 12 views

回答

0

假设您使用PDO。

$stmt = $db->prepare("SELECT * from tblposts where post_by=:post_by"); 
$stmt->bindParam(':post_by',$user); 
$stmt->execute(); 
//Fetches the posts for the certain user you want 
$posts = $stmt->fetch(PDO::FETCH_ASSOC); 

的MySQLi:

$stmt = $mysqli->prepare("SELECT * from tblposts where post_by=?"); 
$stmt->bind_param('s',$user); 
$stmt->execute(); 
$res = $stmt->get_result(); 
while ($row = mysqli_fetch_assoc($res)) { 
    echo $row['post_date']; 
} 
+0

你可以给我MySQLi程序代码,因为我不明白PDO代码吗? –

+0

@MiechChamnan编辑我的评论。添加mysqli –

相关问题