I am trying to format the results of a query.
What I need to do is create a table that has headings on the left and fills the table with the query results.
i.e.
Heading1 result1 result2
Heading2 result1 result2
Heading3 result1 result2
But I don't seem able to do it, I keep getting:
Heading1 result1
Heading2 result1
Heading3 result1
Heading1 result2
Heading2 result2
Heading3 result2
Can anyone help me?!
This is my script:-
<html>
<body>
<?php
$cpu=$_POST['cpu'];
$ffactor=$_POST['ffactor'];
$sound=$_POST['sound'];
$lan=$_POST['lan'];
echo "CPU: $cpu<br>Form Factor: $ffactor<br>Sound: $sound<br>LAN: $lan<hr><br>";
mysql_connect('localhost');
@mysql_select_db('mboards')or die("Unable to connect to selected database.");
$query="SELECT * FROM giga where cpu like '%$cpu%' AND ffactor like '%$ffactor%'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
echo "<table width='355' border='0' cellspacing='0' cellpadding='0'>";
while($i<$num){
$model=mysql_result($result,$i,"model");
$cpu=mysql_result($result,$i,"cpu");
$chipset=mysql_result($result,$i,"chipset");
$ffactor=mysql_result($result,$i,"ffactor");
$fsb=mysql_result($result,$i,"fsb");
$ata=mysql_result($result,$i,"ata");
$agp=mysql_result($result,$i,"agp");
$memslot=mysql_result($result,$i,"memslot");
$memcap=mysql_result($result1,$i,"memcap");
$memtype=mysql_result($result1,$i,"memtype");
$pci=mysql_result($result1,$i,"pci");
$isa=mysql_result($result1,$i,"isa");
$amr=mysql_result($result1,$i,"amr");
$cnr=mysql_result($result1,$i,"cnr");
$sound=mysql_result($result1,$i,"sound");
$lan=mysql_result($result1,$i,"lan");
$other=mysql_result($result1,$i,"other");
//echo "<b>$model</b><br>$cpu<br>$chipset<br>$ffactor<br>$fsb<br><br>";
//echo "<table width='60%' border='0' cellspacing='0' cellpadding='0'>";
//echo "<tr><td width=20 align=left>Model</td><td width=20>CPU</td><td>Chipset</td><td>Form Factor</td><td>FSB</td></tr><br>
// <tr><td>$model</td><td>$cpu</td><td>$chipset</td><td>$ffactor</td><td>$fsb</td></tr>
//</table>";
echo" <td width='10'></td>
<tr height='5'>
<td colspan='7'></td>
</tr>
<tr><td height='1'></td></tr> <tr height='20'>
<td width='10'></td>
<td width='130'><b>Model</font></b></td>
<td width='10'></td>
<td width='95'><b>$model</font></b></td>
<td width='10'></td>
<tr height='5' colspan='7'>
<td colspan='7'></td>
</tr>
<tr valign='top'>
<td width='10'></td>
<td width='130' valign='middle'><b>CPU</font></b></td>
<td width='10'></td>
<td width='95'>$cpu</td>
<td width='10'></td>
<tr height='5'>
<td colspan='7'></td>
</tr>
<tr height='5' colspan='7'>
<td colspan='7'></td>
</tr>
<tr valign='top'>
<td width='10'></td>
<td width='130' valign='middle'>Chipset </td>
<td width='10'></td>
<td width='95'>$chipset</td>
<td width='10'></td>
<tr height='5'>
<td colspan='7'></td>
</tr>
<tr height='5' colspan='7'>
<td colspan='7'></td>
</tr>
<tr valign='top'>
<td width='10'></td>
<td width='130'>Form Factor </td>
<td width='10'></td>
<td width='95' class='small'>$ffactor</td>
<td width='10'></td>
</tr>
<tr height='5' colspan='7'>
<td colspan='7'></td>
</tr>
<tr valign='top'>
<td width='10'></td>
<td width='130'>fsb </td>
<td width='10'></td>
<td width='95' class='small'>$fsb</td>
<td width='10'></td>
</tr>";
++$i;
}
echo "</table>";
?>
</body>
</html>
Someone help please!!