hi!! this is the output im trying to produce..
+------------+--------------------+------------------+-------------------+
|ID| 0001 | 0002 | 0003 |
+------------+--------------------+------------------+-------------------+
|______|6210|6510|6230 |
|_____|Nokia|Nokia|Nokia|
+-------------+--------------------+------------------+-------------------+
| Vib| in phone | in phone | in phone |
+-------------+--------------------+------------------+-------------------+
|Display|Monochrome| Monochrome | Colored |
+-------------+--------------------+------------------+-------------------+
|Radio| No | Yes|Yes__|
+-------------+------------------+-----------------+-------------------+
|Price| Php 3,200.00 | Php 4,500.00| Php 23,000.00|
|___ |______| Php 5,200.00| Php 18,000.00|
|__ | _____|_________| Php 21,000.00|
+------------+------------------+------------------+-------------------+
hehe.. the table doesnt look very good does it..
Price is from a separate table(price), there could be multiple prices for each model.. and the id, model, make, vib, display type etc is in another table(fones).. id is a key common with price and fones.. im having problems pulling up the price..
this is part of what ive got..
<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
foreach($id as $key => $val)
{
if ($id[$key] == 0)
{
$keynxt = $key + 1;
$left = array_slice ($id, 0, $key);
$right = array_slice ($id, $keynxt);
$id = array_merge ($left, $right);
}
}
$query=" SELECT DISTINCT * FROM prize RIGHT JOIN fones2 ON fones2.id = prize.p_id WHERE (fones2.id='$id[0]' || fones2.id='$id[1]' || fones2.id='$id[2]' || fones2.id='$id[3]' || fones2.id='$id[4]') && (prize.p_id='$id[0]' || prize.p_id='$id[1]' || prize.p_id='$id[2]' || prize.p_id='$id[3]' || prize.p_id='$id[4]') ";
$result=mysql_query($query);
$num=mysql_num_rows($result);
$twidth=100+(125*$num);
$cspan= $num+1;
?>
echo '<tr>';
echo '<td bgcolor="#D9E8FF" class="body2"><strong>Camera</td>';
$i=0;
while($i < $num)
{
echo '<td width="125" bgcolor="#D9E8FF" class="body2">';
if ( !strlen(mysql_result($result,$i,"cam"))>0 )
{
echo '--';
}
else
{
if (mysql_result($result,$i,"cam") == 'yes')
{
echo '<img src="images/check.gif"> '.mysql_result($result,$i,"camfeat").'</font>';
}
else
{
echo '<img src="images/cross.gif">';
}
}
echo '</td>';
$i++;
}
echo '</tr>';
echo '<tr>';
echo '<td bgcolor="#D9E8FF"><strong><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Infrared</td>';
$i=0;
while($i < $num)
{
echo '<td width="125" bgcolor="#D9E8FF">';
if ( !strlen(mysql_result($result,$i,"ir"))>0 )
{
echo "--";
}
else
{
if ( mysql_result($result,$i,"ir") == "no" )
{
echo '<img src="images/cross.gif">';
}
else
{
echo '<img src="images/check.gif">';
}
}
echo '</font></td>';
$i++;
}
echo '</tr>';
echo '<tr valign="top">';
echo '<td width="100"><strong><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Price</td>';
$i=0;
while($i < $num)
{
echo '<td width="125">';
echo '<span class="body2">Php '.number_format(mysql_result($result,$i,"priceprize"), 2, '.', ',').'</span><br>';
$i++;
echo '</td>';
}
echo '</tr>';
if each model has 2 prices each, the model column will be displayed twice.. maybe someone has a better idea.. thanks..