dongyang5716 2014-09-01 14:16
浏览 35
已采纳

不要回显先前值中记录的项目

Hi i have a problem retriving items from my database, I want to retrieve the data just one time and if an item was already retrieved in a previous value to not show that item

PHP

$select_query = "select * from posts";

$run_query = mysql_query($select_query);
while($row=mysql_fetch_array($run_query)){
$post_id = $row['post_id'];
$post_title = $row['post_title'];
$post_date = $row['post_date'];
$post_author = $row['post_author'];
$post_image = $row['post_image'];
$post_keywords = $row['post_keywords'];
$post_content = $row['post_content'];

HTML

<h1 class="centru">The Posts Author are: <?php echo $post_author; ?>
</h1>

EX: On the page this will be displayed:
Jhon
Maria
Jhon
Alex
Jhon
I want to be like this
Jhon
Maria
Alex

  • 写回答

2条回答 默认 最新

  • duanpu1064 2014-09-01 14:19
    关注

    If you just want authors, use

    SELECT DISTINCT post_author FROM posts
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?