Jump to content


Photo

What can I use instead??


  • Please log in to reply
3 replies to this topic

#1 crazylegseddie

crazylegseddie
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 21 August 2006 - 11:37 PM

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:

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;	
}

?>

any response will be greatly appreciated :)

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 21 August 2006 - 11:41 PM

Just run them separately, and combine them in PHP.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 crazylegseddie

crazylegseddie
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 22 August 2006 - 06:52 AM

I tried:
$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);

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?  ???


#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 22 August 2006 - 01:42 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users