I'll give this a try. Maybe I'm not communicating what I'm doing properly (I'm a bit new to this).
I have two functions that will get the colors and display:
function get_colors($brand_id)
{
// query database for the books in a category
if (!$brand_id || $brand_id=="")
return false;
$conn = db_connect();
$query = "select * from color where brand_id='$brand_id'";
$result = @($query);
if (!$result)
return false;
$num_books = @mysql_num_rows($result);
if ($num_books ==0)
return false;
$result = db_result_to_array($result);
return $result;
}
and
function display_color_details($color)
{
// display all colors
if (is_array($color))
{
echo "<table><tr>";
echo "<td><table>";
echo "<tr><td>";
echo '<img src="\$color[pic_thumbnail]\" width=100 height=75>';
echo "</td></tr>";
echo "<tr><td>";
echo $color["color_name"];
echo $color["color_num"];
}
else
echo "The details cannot be displayed at this time.";
echo "<hr>";
}
And they are called in a a show_color.php by
// get colors out of db
$color = get_color_details($brand_id);
display_color_details($color);
The $color array is whatever colors are associated to a brand.
There could be 1 to 50 colors per brand.
John