I’m trying to retrieve data fields from two tables in the same database and create a printout out from the records. I get no data from either?
[code=php]<?php
include(“getinvno.php”);
$rate = $row[‘rate’];
mysql_connect(“localhost”, “root”, “”);
mysql_select_db(posdb) or die(“Unable to select database”);
$query = “SELECT * FROM saledata AS t1 INNER JOIN postable AS t2 WHERE t1.itemno = t2.itemno
AND t2.itemno = ‘{$itemno}'”;
$result=mysql_query($query);
$num=mysql_numrows($result);
echo “<center><font size=+2><b> Kirk Pawn, Gun & Archery</font><br />”;
echo “9921 Old Bearskin Rd<br />”;
echo “Hunters Den, Alabama 32145<br /></center>”;
echo “customer# “.$data[‘invno’];
echo “.. </b><br />”;
echo “tax rate “.$data[‘rate’];
echo “.. </b><br />”;
echo “<table cellspacing=1 cellpadding=1 border=0>
<tr>
<th>Qty</th>
<th></th>
<th></th>
<th>Unit</th>
<th>Amt</th>
<tr>
<th>Sold</th>
<th>item#</th>
<th>item</th>
<th>Price</th>
<th>Due</th>
<tr>
<TH colspan=5>———————————————————————————————</TH>
</tr>”;
while($row = mysql_fetch_array($result))
{
$tax = $sellprice * $rate;
$taxtotal = $taxtotal + $tax;
$amtdue = $sellprice * $sellqty;
$amtdue = $amtdue + $tax;
$total = $total + $amtdue;
$onhand – $onhand – $sellqty;
echo “<tr>”;
echo “<td>” . $row[‘sellqty’] . “</td>”;
echo “<td>” . $row[‘itemno’] . “</td>”;
echo “<td>” . $row[‘itemdescr’] . “</td>”;
echo “<td align=right>” . $row[‘sellprice’] . “</td>”;
echo “<td align=right>” . $row[‘amtdue’] . “</td>”;
}
echo “<tr>”;
echo “<TH
colspan=5>========================================================</TH>”;
echo “<tr>”;
echo “<td>Tax</td>”;
echo “<td></td>”;
echo “<td></td>”;
echo “<td></td>”;
echo “<td align=right>” . sprintf(“%.2f”,$taxtotal) .
“</td>”;
echo “<tr>”;
echo “<TH
colspan=5>========================================================</TH>”;
echo “<tr>”;
echo “<td>Total</td>”;
echo “<td></td>”;
echo “<td></td>”;
echo “<td></td>”;
echo “<td align=right>” . sprintf(“%.2f”,$total) .
“</td>”;
echo “</tr>”;
echo “</table>”;
$sql = “UPDATE postable SET
onhand = ‘” . mysql_real_escape_string($onhand) . “‘
WHERE itemno='”.$_POST[“itemno”].”‘”;
mysql_query($sql) or die(“Update query failed.”);
echo “<b>We thank you for your business</b><br />”;
?>