What about something like this? The database structure would be something like the following (in case the array doesn't make sense).
ID | Product | Desc | Attr
---------------------------
ID would hold the product's ID number (unique key, auto increment).
Product would hold the product name.
Desc would hold the description
Att would hold the attributes (like size, color, gender...) in the following format.
Attr: Value;
Size: 9;
$db = array(
array('ID' => '1',
'Product' => 'Wallet',
'Desc' => 'A red wallet',
'Attr' => 'Color: Red;'
),
array('ID' => '2',
'Product' => 'Shoe',
'Desc' => 'A walking shoe',
'Attr' => 'Color: White;
Gender: Female;
Size: 11.5;'
),
array('ID' => '3',
'Product' => 'Laptop',
'Desc' => 'A Dell Inspiring Laptop',
'Attr' => 'Color: Silver;
Size: 19";'
),
array('ID' => '4',
'Product' => 'Sock',
'Desc' => 'Nike Sock',
'Attr' => 'Color: White;
Size: 9;'
),
);
foreach($db as $key => $desc)
{
if(!empty($desc))
{
echo "<strong>Product:</strong> {$desc['ID']} {$desc['Product']}<br />\n";
echo "<strong>Description:</strong> {$desc['Desc']}<br />\n";
echo "<ul>\n";
$attr = preg_replace("/(\w+(?::))/i", "<li><strong>$1</strong>", $desc['Attr']);
echo preg_replace("/(\w+(?:;))/i", "$1</li>\n", $attr);
echo "</ul>\n";
echo "<hr />\n";
}
}
?>
It's going to display all that as:
Product: 1 Wallet
Description: A red wallet
* Color: Red;
_________________________________________________________________
Product: 2 Shoe
Description: A walking shoe
* Color: White;
* Gender: Female;
* Size: 11.5;
_________________________________________________________________
Product: 3 Laptop
Description: A Dell Inspiring Laptop
* Color: Silver;
* Size: 19";
_________________________________________________________________
Product: 4 Sock
Description: Nike Sock
* Color: White;
* Size: 9;
_________________________________________________________________