I am tyring to set up a script to run on a cron job which automatically updates the status of my orders to shipped based on a feed that my suppliers send me.

I am currently working on the reading the feed bit to get the status but was hoping someone can help me get the code right for the order update part. My assumption is that the following needs to happen:

select * from orders where orders_status = 2; //where order status 2 is processing

while { //run a while loop for each order that is in processing status

$orders_id = result; // define which order id we are currently dealing with

do the xml thing here

$new_status = "Shipped"; //defined by pulling ht einfo from my feed from supplier

if ($new_status = Shipped) { //if the current order id is found to be Shipped status do the following:

//this is the part I need help with...

//1. update order status, pretty sure this is correct
Update orders SET orders_status = 3 WHERE orders_id = $orders_id; // where order status = 3 is Shipped

//2. insert some values into order history and set if they can be veiwed by customer or not??
INSERT into orders_status blar, blar blar;

//3. send order update email to customer, not sure how this should be?
zen_mail (.... customer whos order id = $order_id

}

} move_next

exit;

Thanks in advance

Phil