i have two tables rsales and salessumarry and i have this ff value.
value from salessumarry
date | receipt |
09/29/2103 | 112233 |
values from rsales
name | category | receipt |
33uf | capacitor | 112233 |
ic | ic22 | 112233 |
THE EXPECTED OUTPUT MUST BE SOMETHING LIKE THIS.
date | receipt |
09/29/2103 | 112233 |
*name | category | receipt |*
33uf | capacitor | 112233 |
ic | ic22 | 112233 |
but i get a result like this which is wrong. i have my code below so far.
date | receipt |
09/29/2103 | 112233 |
*name | category | receipt |*
33uf | capacitor | 112233 |
*name | category | receipt |*
ic | ic22 | 112233 |
and i have this ff code so far
$a=$_POST['dayfrom'];
$b=$_POST['dayto'];
$result1 = mysql_query ("SELECT s.*, r.category, r.name,r.receipt
FROM salessumarry s
JOIN rsales r ON s.reciept = r.reciept
WHERE s.register_mode = 'sales'
AND s.date BETWEEN '$a' AND '$b' ");
while($row = mysql_fetch_array($result1))
{
echo '<tr>';
echo '<td style="border-color:#000000; border-style:solid; border-width:1px;"><div align="center">'.$row['date'].'</div></td>';
echo '<td style="border-color:#000000; border-style:solid; border-width:1px;"><div align="center">'.$row['reciept'].'</div></td>';
echo '</div></td>';
echo '</tr>';
echo '<th style="border-color:#000000; border-style:solid; border-width:1px;"><div align="center">'.$row['name'].'</div>
echo '<th style="border-color:#000000; border-style:solid; border-width:1px;"><div align="center">'.$row['category'].'</div></th>';
echo '<th style="border-color:#000000; border-style:solid; border-width:1px;"><div align="center">'.$row['receipt'].'</div></th>';
echo '<tr>';
echo '<th style="border-color:#000000; border-style:solid; border-width:1px;font-size:10px;background-image:url(images/buts3.png);color:white"">name</th>';
echo '<th style="border-color:#000000; border-style:solid; border-width:1px;font-size:10px;background-image:url(images/buts3.png);color:white"">category</th>';
echo '<th style="border-color:#000000; border-style:solid; border-width:1px;font-size:10px;background-image:url(images/buts3.png);color:white"">receipt</th>';
}
mysql_close($con);
?>
I'm sorry If I have misunderstood the question- the code you posted does not seem to produce the output you posted, nevertheless, here's my two cents; I think that to fix the problem you are having with the table headers repeating throughout the results, you need to place the block which reads:
echo '<tr>';
echo '<th style="border-color:#000000; border-style:solid; border-width:1px;font-size:10px;background-image:url(images/buts3.png);color:white"">Product Code</th>';
echo '<th style="border-color:#000000; border-style:solid; border-width:1px;font-size:10px;background-image:url(images/buts3.png);color:white"">Name</th>';
In side an if block, such that it only displays once:
if(!$displayed) {
$displayed = true;
echo '<tr>';
echo '<th style="border-color:#000000; border-style:solid; border-width:1px;font-size:10px;background-image:url(images/buts3.png);color:white"">Product Code</th>';
echo '<th style="border-color:#000000; border-style:solid; border-width:1px;font-size:10px;background-image:url(images/buts3.png);color:white"">Name</th>';
}
And do not forget to initialize $displayed to false before the while loop.
In addition, but somewhat aside from the actual question this code you have posted is very insecure, as it is vulnerable to an attack known as sql injection. I recommend you use something like PDO prepared statements to make sure that you do not suffer security problems.