您好,我在从数据库中检索项目时遇到问题,我只想检索一次数据,并且如果已在先前值中检索到某个项目,则不显示该项目
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:页面上将显示:
乔恩
玛丽亚
乔恩
亚历克斯
乔恩
我想成为这样的
约翰
玛丽亚
亚历克斯
最佳答案
如果您只需要作者,请使用
SELECT DISTINCT post_author FROM posts
关于php - 不回显先前值中记录的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25607785/