2017-08-06 15 views
0

私はこのようなデータベースの構造を有する:PHPとMySQLの1ページでユーザーごとのポストを表示するには?

enter image description here

table name: tblpostをし、私はページ名に複数のユーザーによるショーのポストのようなユーザーによるすべての投稿を表示する:


allpost.php

enter image description here

は、私はこのような結果を取得したいです

どのようにデータを表示するのですか?すべてのあなたの答えに感謝します。

+0

、あなたはあなたの試みを示す質問を編集することができますしてください? – alepuzio

答えて

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

PDOコードを理解できないため、MySQLi手続き型コードを教えてもらえますか? –

+0

@MiechChamnanが私のコメントを編集しました。 mysqliが追加されました –

関連する問題