But I have a very pressing question, I think I have solved the theory that would go into this problem/task.
I work on an ecommerce system, and it is paramount that we get our orders right (asin not duplicating orders!).
I just wanted to get some idea of how to approach this in a practical form.
Enough waffle here we go:
A user clicks on the link that generates the report.
We have the following showing up:
productid
cost_price
amount
productcode
product
fmdate (date order was placed by the customer)
total (cost_price x by amount (amount refers to quantity!)
What we have is a field in the database called 'status' this is set to P (stands for processed) (if they have placed an order successfully).
What I was wanting to know was how would I set the 'status' field to C (stands for complete) when a user clicks on a link that says complete all orders listed above, for all results found in a list?
This is the code I have so far and this is working fine:
Code: Select all
<html>
<head>
<title>Shopping Cartridge World : X Cart : Purchasing Report</title>
</head>
<body>
<h3>Shopping Cartridge World : X Cart : Purchasing Report</h3>
<?php
$host = 'localhost'; // Sets the variable host as a literal no parsing for db connections
$user = 'xcart'; // username
$passwd = 'xcart0r'; // db password (abbreviated to unix password command)
$dbname = 'xcart';
$conn = mysql_connect($host, $user, $passwd) or die();
mysql_select_db($dbname);
// Working SQL just doesnt times by quantity and then final cost price as a whole!
$db_query = "SELECT A1.productid, SUM(A2.price) AS cost_price, SUM(A1.amount) AS amount, A1.productcode, A1.product, DATE_FORMAT(FROM_UNIXTIME(A3.date), '%e/%c/%Y') AS fmtdate, SUM(A2.price * A1.amount) AS total
FROM xcart_order_details A1
LEFT JOIN xcart_pricing A2 ON A1.productid = A2.productid
LEFT JOIN xcart_orders A3 ON A1.orderid = A3.orderid
WHERE A2.membershipid = '2' AND A3.status = 'P'
GROUP BY A1.productid
ORDER BY A1.orderid";
$result = mysql_query($db_query);
echo '<table border=0 width="80%" cellpadding="4">';
// Header columns
echo '<tr>';
echo '<td><strong>Date</strong></td>' . '<td><strong></strong></td>' . '<td><strong>Productcode</strong></td>' . '<td><strong>Product</strong></td>' . '<td><strong>Cost Price</strong></td>' . '<td><strong>Quantity</strong></td>' . '<td><strong>Total</strong></td>';
echo '</tr>';
// SQL results
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo '<tr>';
echo '<td>' . "{$row['fmtdate']}" . '</td>' . '<td>' . "{$row['orderid']}" . '</td>' . '<td>' . "{$row['productcode']}" . '</td>' . '<td>' . "{$row['product']}" . '</td>' . '<td>' . "{$row['cost_price']}" . '</td>' . '<td>' . "{$row['amount']}" . '</td>' . '<td>' . "{$row['total']}" . '</td>';
echo '</tr>';
}
echo '</table>';
?>
<table>
<tr>
<td colspan=2> </td>
</tr>
<tr>
<td><a href="#" onClick="history.go(-1)">Back</a></td>
<td><a href="http://shopping.cartridgeworld.co.uk/purchasing/purchase_Export.php">Export CSV</a></td>
</tr>
</table>
</body>
</html>
Thanks in advance,
Jeremy.
PS Just had a thought, wouldnt it be easier using a text button? Like a hidden field with the value of C and then getting that to fill in all the results at present? It surely would be just a matter of writing that code.
But for the life of me I cant remember how to do this for all fields, can someone help still?