crazylegseddie Posted August 21, 2006 Share Posted August 21, 2006 Hi everyone. I followed a tutorial script to complete a shopping basket site. Currently the script uses UNION to combine the queries but I just realised the server I am using uses an older version of mySQL that does not support the UNION function, so can anyone help me out and tell me what I can use as a replacement?? Heres the script:[code=php:0]function getOrderAmount($orderId){ $orderAmount = 0; $sql = "SELECT SUM(pd_price * od_qty) FROM tbl_order_item oi, tbl_product p WHERE oi.pd_id = p.pd_id and oi.od_id = $orderId UNION SELECT od_shipping_cost FROM tbl_order WHERE od_id = $orderId"; $result = dbQuery($sql); if (dbNumRows($result) == 2) { $row = dbFetchRow($result); $totalPurchase = $row[0]; $row = dbFetchRow($result); $shippingCost = $row[0]; $orderAmount = $totalPurchase + $shippingCost; } return $orderAmount; }?>[/code]any response will be greatly appreciated :) Quote Link to comment https://forums.phpfreaks.com/topic/18249-what-can-i-use-instead/ Share on other sites More sharing options...
fenway Posted August 21, 2006 Share Posted August 21, 2006 Just run them separately, and combine them in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/18249-what-can-i-use-instead/#findComment-78344 Share on other sites More sharing options...
crazylegseddie Posted August 22, 2006 Author Share Posted August 22, 2006 I tried: [code=php:0]$sql = "SELECT SUM(pd_price * od_qty) FROM tbl_order_item oi, tbl_product p WHERE oi.pd_id = p.pd_id and oi.od_id = $orderId"; $result = dbQuery($sql); $sql2 = "SELECT od_shipping_cost FROM tbl_order WHERE od_id = $orderId";$result = dbQuery($sql2);[/code]but no matter what i add to my cart this gave me a total of 0 when I processed the ammount in paypal? Is this because Im not combining the two queries with PHP? If not how can I do that? ??? Quote Link to comment https://forums.phpfreaks.com/topic/18249-what-can-i-use-instead/#findComment-78459 Share on other sites More sharing options...
fenway Posted August 22, 2006 Share Posted August 22, 2006 Well, you'll need to iterate though each result set separately, then store the results elsewhere. Unfortunately, I know absolutely nothing about PHP, so I can't tell you how to do it other than to describe the pseudo-code. Quote Link to comment https://forums.phpfreaks.com/topic/18249-what-can-i-use-instead/#findComment-78584 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.