Hi all,
I have a function that currently working. It displays a set of results based on criteria etc. I've been trying to count the number of results returned, but seem to be hitting a brick wall. here is my code:
function listItemsInvoice($txn_id_i)
{
// Performing SQL query
$txn_id_i = mysql_real_escape_string($txn_id_i);
$query = "select * from ipn_trans LEFT JOIN ipn_item ON ipn_trans.id=ipn_item.parent_id where ipn_trans.txn_id='$txn_id_i' ORDER BY ipn_trans.time DESC;";
$result = mysql_query($query) or die('Query failed: ' . $query . ' '. mysql_error());
if (!$result) {
//echo "ERR";
return;
}
$invoice = '';
$processed = array($txn_id_i => 'new');
if (mysql_num_rows($result) != 0) {
while ($row = mysql_fetch_assoc($result)) {
if ($processed[$txn_id_i] != $row['payment_status']) {
if ($processed[$txn_id_i] == 'new')
$processed[$txn_id_i] = $row['payment_status'];
else
continue;
$item_number = $row['item_number'];
$item_name = $row['item_name'];
$type = $row['option_selection1'];
$finish = $row['option_selection2'];
$quantity = $row['quantity'];
$net = $row['mc_gross'];
}
$invoice .= "<tr>
<td width=\"100\" align=\"left\" style=\"font:Arial; font-size:12px; color:#000000; padding-bottom:5px;\">($r)$item_number</td>
<td width=\"350\" align=\"left\" style=\"font:Arial; font-size:12px; color:#000000; padding-bottom:5px;\">$item_name ($type | $finish) </td>
<td width=\"100\" align=\"center\" style=\"font:Arial; font-size:12px; color:#000000; padding-bottom:5px;\">$quantity</td>
<td width=\"100\" align=\"right\" style=\"font:Arial; font-size:12px; color:#000000; padding-bottom:5px; padding-right:10px;\">£$net</td>
</tr>";
}
}
mysql_free_result($result);
return $invoice;
};
I'd really appreciate some help with this as its been driving me mad!!
cheers
Mark