2011-10-24 35 views
1

如何讓我的php頁面只返回具有某個id的行。我正在建立一個像博客一樣的網頁,我使用mysql後,我只顯示ID爲1的條目,所以我不必擔心刪除舊帖子或在1頁上有100個帖子。我怎樣才能讓我的php只返回來自mysql的某個id

 <?php 
     include ("includes/includes.php"); 

     $blogPosts = GetBlogPosts(); 

     foreach ($blogPosts as $post) 
     { 
      echo "<div class='post'>"; 
      echo "<h2>" . $post->title . "</h2>"; 
      echo "<p>" . $post->post . "</p>"; 
      echo "<br />"; 
      echo "<span>Posted By: " . $post->author . "&nbsp Posted On: " . $post->datePosted . "&nbsp Tags: " . $post->tags . "</span>"; 
      echo "</div>"; 
     } 

     ?> 
+2

後你到目前爲止的代碼。 – Nasreddine

+1

您可以通過使用SELECT查詢。例如:'添加標題,內容,日期FROM條目WHERE id = 1' – GolezTrol

+0

代碼已添加。 – zarath

回答

1
$result = mysql_query("SELECT * FROM entries WHERE id=1");