Hi Thanks for both replying.
Yes The example of product A and B is how I want them to be displayed in my web page. I have one big table with about 35 columns but each product probably only uses 4 of these columns so there is a lot of empty fields in the table.
I have got around the problem of having to have lots of if statements to show only relevant columns for each product. I did this by itering through the key and values of each array returned from the database.....as show below;
$r = mysqli_query($dbc, "select * from tFullVariables where productId = $pid");
if(mysqli_num_rows($r) > 0)
{
$mybody = "";
//starts the table and header row
$head='<table id="prodoptions" cellspacing="1" border="1"><tr class="head">';
//$c is the counter so that the header is only show once
$c = 1;
while($myrecord = mysqli_fetch_array($r, MYSQLI_ASSOC))
{
$mybody .= '<tr>';
//loops through each key and value of the results array returned by the database
foreach($myrecord as $key => $value)
{
//if the value of the field is empty or 0 then dont show the column or field
if($value <> "" && $value <> " " && $value <> "0.00" && $key <> 'id' && $key <> 'productId' )
{
if($c ==1)
{
$head .= '<th>'.$key.'</th>';
}
$mybody .= '<td>'.$value.'</td>';
}
}
$mybody .= '</tr>';
$c=2;
}
//displays the column headers
echo $head.'</tr>';
//displays all of the relevant fields
echo $mybody.'</table>';
}
If any one can think of a way of doing the above in a relational way using multiple tables instead of one big table that would be good.
Thanks