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
https://forums.phpfreaks.com/topic/64705-solved-removing-multiple-values/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.