Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

SQL query - how to select orders_id & amount


btaneja

Recommended Posts

Posted this in the Development forum without luck. So trying here.

 

This should be easy.. Just need to select two items from the database. I can do this with a vanilla php script, but using oscommerce functions/ integration has me confused.

 

I have spent half a day on this but being not so good with php or the internals of Oscommerce, I am lost..

 

I want to select amount and orders_id into a variable like this.

 

In checkout_success.php:

 

$orders_query = tep_db_query("select max(orders_id) from " . TABLE_ORDERS . " where customers_id = '" . $customer_id . "' order by date_purchased desc limit 1");

$orders = tep_db_fetch_array($orders_query);

 

$xoid=$orders['orders_id'];

<?php <html> <body> echo "$xoid"; </body> <html> ?>

 

 

 

$amount_query = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $orders['orders_id'] . "'and title='Total:'");

$amounts = tep_db_fetch_array($amount_query);

$amnt=$amounts["value"];

<?php <html> <body> echo "$amnt"; </body> <html> ?>

 

 

#### Then in the section where the <html> section of the checkout_success is and where all the echo and prints are: I did:

 

<?php

echo " CustomerID: $customer_id <p>";

echo " Amount: $amnt <p>";

echo " Order ID: $xoid <p>";

?>

 

 

######### Here is what I get:

 

CustomerID: 9 # this is ok

Amount:

Order ID:

 

How can I get the value and orderID values into variable I can use? Please help !

 

 

 

thank you !!!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...