kersh86 Posted July 18, 2012 Share Posted July 18, 2012 Hi guys what im trying to do is to get information from the database in this sense eg: this is the database information i am trying to get: Albion taupe tan blue churchhill blue tan white but it keeps coming out like this: Albion taupe taupe taupe churchhill blue blue blue as you can see it driving me mad, i know my queries are correct as i tested them in the sql in phpmyadmin. im guessing that it because i have 2 while loops 1 within the other, but i just cant figure out how to implement this. any adive would be great and here is a snippet of my code im using at the moment: if($name == "all") { echo "<div id='colours'><p>Colours Available:</p>"; $r2 = mysql_query("SELECT name, colour from collections WHERE name = '".$row['name']."'") or die("Error getting Products: <br /> Variable: ".$name."<br /> Error: ".mysql_error()); while($row2 = mysql_fetch_assoc($r2)){ $colour = str_replace(" ","-",$row['colour']); echo "<img id='swatches' src='images/swatches/".strtolower($colour).".png' width='18px;' height='18px' title='".$colour."' />"; } } Quote Link to comment https://forums.phpfreaks.com/topic/265906-query-repeats-value-when-i-want-the-individual-values/ Share on other sites More sharing options...
Barand Posted July 18, 2012 Share Posted July 18, 2012 try SELECT DISTINCT colour WHERE name = .... Quote Link to comment https://forums.phpfreaks.com/topic/265906-query-repeats-value-when-i-want-the-individual-values/#findComment-1362466 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.