I am trying to format the results of my query.
This is my script at present:-
<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;
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 "<table width='355' border='.01' cellspacing='0' cellpadding='0'>
<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>
</table>";
++$i;
}
?>
</body>
</html>
If you run this script, then you will see that a new table is created for every result there is.
What I need to do is have just one table containing all the results.
I think I might need to use an array, but I am not sure.
Can anyone help me pls?
Thanks