Hey LordShryKu,
Many thanks for responding and quickly !
May be I need to explain my problem more clearly.
This is for ashopping cart in the UK for a report which
outputs, Order total, Shipping total and VAT (tax) in
three columns against each order for a purticular Period(quarterly)
Sort orders, 1,2 and 3 are allocated respectively.
The code try extracts from an order table the relevent orde_id
and info and from a second Orders_total table only the VALUE
(text) and the sort order.
The code then insert all that in to the TEMP table and extrcts
Sort orders1,2and 3 with the text values in 3 arrays used
for outputting the table.
My basic problem is that as I modify the orders
to not show VAT(TAX) for non EU customers. Hence
VAT and sort order 3 is nonexistent for non EU orders.
In addition in some cases Shipping Sort order 2 is non existent.
So the data still gets mixed up as the arrays pick them up
sequentially only where the respective sort order is available.
When the table is finally out put the upwardly compressed
arrys2 and 3 supply wrong values(some other ids's values)
$sel_tax_1 = tep_db_query("select orders_id, date_purchased, customers_name, customers_country, orders_status, currency, currency_value, text from " . ORDERS_TEMP . " where sort_order = 3 order by vat_order_temp1.orders_id asc");
$sel_tax_2 = tep_db_query("select orders_id, text from " . ORDERS_TEMP . " where sort_order = 2 order by vat_order_temp1.orders_id asc");
Here is a sample output:
United Kingdom
Order No. Purchase Date Customers Name Customers Country Original Currency VAT Amount Shipping Cost Total (pre tax/shipping)
51 2003-07-05 06:48:44 Tim Arpino United Kingdom GBP £24.00 £8.00 £4.63
The last value in the above is correct but the other two (£24 and £8)
are coming fom a upwardly compressed array ( as there are missing values )
What I need is that in the Second and third arrays, sort order
2 and 3 "text" is only picked up for the order Id IF EXISTING
otherwise put a NULL or O Value
I imagine that this is a typical DATABASE situation and
some eay way of doing it must be out there though i can't get fromOSC
I have cooked up something !
tep_db_query("INSERT INTO " . ORDERS_TEMP . " (orders_id, date_purchased, customers_name, customers_country, orders_status, currency, currency_value, text, sort_order) SELECT orders.orders_id, orders.date_purchased, orders.customers_name, orders.customers_country, orders.orders_status, orders.currency, orders.currency_value, orders_total.text, orders_total.sort_order FROM " . TABLE_ORDERS . ", orders_total WHERE orders.orders_id = orders_total.orders_id and orders.date_purchased > '" . $start_year. "-" . $start_date . " 00:00:00' and orders.date_purchased < '" . $end_year. "-" . $end_date . " 00:00:00'");
$sel_tax_1 = tep_db_query("select orders_id, date_purchased, customers_name, customers_country, orders_status, currency, currency_value, text from " . ORDERS_TEMP . " where sort_order = 1 order by vat_order_temp1.orders_id asc");
while ($sel_tax_1_array = tep_db_fetch_array($sel_tax_1))
foreach ($sel_tax_1.orders_id as$orderid ){
if (!$sel_tax_1_sortorder = 2) {
$sel_tax_2_text=0;
$sel_tax_2 =tep_db_query("select orders_id, text from " . ORDERS_TEMP . " where sort_order = 2 order by vat_order_temp1.orders_id asc");
}
if (!$sel_tax_1_sortorder = 3) {
$sel_tax_3_text=0;
$sel_tax_3 = tep_db_query("select orders_id, text from " . ORDERS_TEMP . " where sort_order = 3 order by vat_order_temp1.orders_id asc");
}
ould you please suggest if this will work or
how I can use your earlier suggestion
Many thanks for sparing some moments of your weekend.
----- Original Message
$sel_tax_1 = tep_db_query("select orders_id, date_purchased, customers_name, customers_country, orders_status, currency, currency_value, text from " . ORDERS_TEMP . " where sort_order = 3 order by vat_order_temp1.orders_id asc");
tep_db_query("INSERT INTO " . ORDERS_TEMP . " (orders_id, date_purchased, customers_name, customers_country, orders_status, currency, currency_value, text, sort_order) SELECT orders.orders_id, orders.date_purchased, orders.customers_name, orders.customers_country, orders.orders_status, orders.currency, orders.currency_value, orders_total.text, orders_total.sort_order FROM " . TABLE_ORDERS . ", orders_total WHERE orders.orders_id = orders_total.orders_id and orders.date_purchased > '" . $start_year. "-" . $start_date . " 00:00:00' and orders.date_purchased < '" . $end_year. "-" . $end_date . " 00:00:00'");