Is there a way to echo this only once and not have it repeat?

Posted by Fernando on Stack Overflow See other posts from Stack Overflow or by Fernando
Published on 2010-03-27T17:48:13Z Indexed on 2010/03/27 17:53 UTC
Read the original article Hit count: 176

Filed under:
|

I have the following query:

    $select = mysql_query("SELECT * FROM posts WHERE id = $postIds");

    while ($return = mysql_fetch_assoc($select)) {

        $postUrl      = $return['url'];
        $postTitle    = $return['title'];

        echo "<h1><a href='$postUrl'>".$postTitle."</a></h1>";

    }

Now the problem is, the variable $postIds often times contain the same id multiple times. So the title of the post echos itself multiple times. Is there a way to have it echo only once?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql