Jump to content

Query Repeats Value When I Want The Individual Values


kersh86

Recommended Posts

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."' />";
}
}

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.