Hello!
I am fetching some names from MySQL and i want to remove duplicated strings.

Currently got this code:

function get_PublicAlbums(){
$sql = "SELECT * FROM `ue-userfile` WHERE public=1";
$result = mysql_query($sql);
$html = "";
while($row = mysql_fetch_array($result))
   {
	$albumname = $row['albumname'];
	
	
	$html .= '<p><a href="index.php?page=public-albums&an='.$albumname.'">'.$albumname.'</a></p><br/>';
	
   }
/* It might be more than one $row['albumname'](Nature) so i only want to show one of them.
I need some help on that logic, i might be dumb. */
 return $html;

}

Regards,
Morten(Norway)

Recommended Answers

All 4 Replies

Member Avatar for diafol
$sql = "SELECT DISTINCT albumname FROM `ue-userfile` WHERE public=1

I will try that as soon as i get home. I appreciate the replys, thanks! :D

$sql = "SELECT DISTINCT albumname FROM `ue-userfile` WHERE public=1

Didn't work in this case, this is what albumname looks like in the db.
albumname | varchar(20)

and it look something like this inside.
Nature
Nature
Nature
Family
Family
Family

I know how i can do this in flat-file .txt organizing but i wanted this one from the DB.

Fixed it with SELECT DISTINCT as ardav said.
Solved,thanks! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.