Jump to content

[SOLVED] Removing multiple values


dizzyvapor

Recommended Posts

I'm still pretty new at PHP so I'm sorry if this is a simple question. On the homepage of my site I am trying to display the titles of my most recent wordpress blogs. However, I don't want it to show more than one result with the same value. I just want it to show the first result with that value.

 

Here is my code:

 

<?php

 

$query = "SELECT * FROM wp_posts ORDER BY id desc LIMIT 0, 5";

 

$result = mysql_query( $query, $connect );

 

while( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ){

 

?>

<ul>

<li><a href="<?php echo 'http://www.blog.mysiteurl.com/?p='.$row['ID']; ?>"><?php echo  $row['post_title']; ?></a></li>

 

<?php

 

}

 

mysql_close( $connect );

 

?>

</ul>

Link to comment
Share on other sites

$query = "SELECT * FROM wp_posts ORDER BY id desc LIMIT 0, 5";

 

That grabs the first 5 results starting at 0

 

Change it to

 

$query = "SELECT * FROM wp_posts ORDER BY id desc LIMIT 1";

 

That's not what I'm looking for. I want duplicate values from the database not to show. For instance if there is more than one post title with the value of "hello", I just want the first "hello" to show up.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.