Jump to content

Recommended Posts

I'm "TRYING" utilizing the following code and can't seem to get a valid resource.

[code]$result = mysql_query('SELECT sum(product.itemprice * cart.quantity) as price FROM ".TABLE_PREFIX."p827_shop_product product, ".TABLE_PREFIX."p827_shop_cart cart WHERE cart.session=\''.$this->get_sess().'\' AND product.pid = cart.pid');
[/code]

My table names have a prefix.

".TABLE_PREFIX."p827_shop_product
".TABLE_PREFIX."p827_shop_cart

I've been messing with this for hours would one of you re-write the query or point me to my failure please.
This is beyond my understanding.

Here's the whole function

Thanks for looking guys.[code]function total()
{
   global $DB;//         Price from the product table and the quntity from the carts table
$query ="SELECT sum(".TABLE_PREFIX."p827_shop_product.itemprice * ".TABLE_PREFIX."p827_shop_cart.quantity) as price FROM ".TABLE_PREFIX."p827_shop_product, ".TABLE_PREFIX."p827_shop_cart WHERE ".TABLE_PREFIX."p827_shop_cart.session=\''.$this->get_sess().'\' AND ".TABLE_PREFIX."p827_shop_product.pid = ".TABLE_PREFIX."p827_shop_cart.pid";

$result = mysql_query($query);
$row = mysql_fetch_array($result);
return $row['price'];
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/9501-query-restructure/
Share on other sites

[!--quoteo(post=373090:date=May 10 2006, 03:50 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ May 10 2006, 03:50 PM) [snapback]373090[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Not sure why you're escaping your single quotes, or why you don't have a concat operator after your '/'.
[/quote]


Super Sweet! thank you.
Link to comment
https://forums.phpfreaks.com/topic/9501-query-restructure/#findComment-35086
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.