latheesan
10-05-2009, 02:02 PM
Hey,
I have two tables on my database:
product_list
- id
- product_name
- supplier_dropship_cost_price
- dropship_addon_percent
- supplier_bulkbuy_cost_price
- bulkbuy_addon_percent
- min_bulkbuy_quantity
my_cart
- id
- account_id
- product_id
- type
- pack_of
- amount
I want to show a list of items in the logged in user's cart (if any). I tried to retrieve the desired data by using the following query:
$query = "";
$query .= "SELECT ";
$query .= "`my_cart`.`id`, `my_cart`.`account_id`, `my_cart`.`product_id`, `my_cart`.`type`, `my_cart`.`pack_of`, `my_cart`.`amount` ";
$query .= "`product_list`.`supplier_dropship_cost_price`, `product_list`.`dropship_addon_percent`, `product_list`.`supplier_bulkbuy_cost_price`, `product_list`.`bulkbuy_addon_percent`, `product_list`.`min_bulkbuy_quantity`, `product_list`.`product_name` ";
$query .= "FROM `my_cart` ";
$query .= "LEFT JOIN `product_list` ON `product_list`.`id` = `my_cart`.`product_id` ";
$query .= "WHERE ( ";
$query .= "`my_cart`.`account_id` = %d";
$query .= ")";
When i ran the query in phpMyAdmin to test if it was correct and i got this error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`supplier_dropship_cost_price`, `product_list`.`dropship_addon_percent`,' at line 1
What im i doing wrong here? Thanks in advance for any help/tip.
I have two tables on my database:
product_list
- id
- product_name
- supplier_dropship_cost_price
- dropship_addon_percent
- supplier_bulkbuy_cost_price
- bulkbuy_addon_percent
- min_bulkbuy_quantity
my_cart
- id
- account_id
- product_id
- type
- pack_of
- amount
I want to show a list of items in the logged in user's cart (if any). I tried to retrieve the desired data by using the following query:
$query = "";
$query .= "SELECT ";
$query .= "`my_cart`.`id`, `my_cart`.`account_id`, `my_cart`.`product_id`, `my_cart`.`type`, `my_cart`.`pack_of`, `my_cart`.`amount` ";
$query .= "`product_list`.`supplier_dropship_cost_price`, `product_list`.`dropship_addon_percent`, `product_list`.`supplier_bulkbuy_cost_price`, `product_list`.`bulkbuy_addon_percent`, `product_list`.`min_bulkbuy_quantity`, `product_list`.`product_name` ";
$query .= "FROM `my_cart` ";
$query .= "LEFT JOIN `product_list` ON `product_list`.`id` = `my_cart`.`product_id` ";
$query .= "WHERE ( ";
$query .= "`my_cart`.`account_id` = %d";
$query .= ")";
When i ran the query in phpMyAdmin to test if it was correct and i got this error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`supplier_dropship_cost_price`, `product_list`.`dropship_addon_percent`,' at line 1
What im i doing wrong here? Thanks in advance for any help/tip.
