koollayed Posted October 11, 2010 Posted October 11, 2010 I have a question I know you guys can help. I added a new rows (member_flag1) (member_flag2) to "customers" in my database because I want to restrict accesses to a page. By default when they create an account the row is 0. What I want to do is when they buy a specific product change this row from 0 to blank. For example John buys a brush after he buys member_flag1 is changed to blank. He comes back and buys a hat after he buys member_flag2 is changed. Can anyone help with this. Thanks
♥geoffreywalton Posted October 11, 2010 Posted October 11, 2010 It is along the lines of If product_id = '12345' { Update customer set member_flag2 = ' ' where customer_id = '123' } Probably needs to go in the loop where the check for notifications is done, which is probably in checkout_sucess.php. For more info on mysql & php syntax have a look at www.w3schools.com HTH G Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile Virus Threat Scanner My Contributions Basic install answers. Click here for Contributions / Add Ons. UK your site. Site Move. Basic design info. For links mentioned in old answers that are no longer here follow this link Useful Threads. If this post was useful, click the Like This button over there ======>>>>>.
koollayed Posted October 11, 2010 Author Posted October 11, 2010 It is along the lines of If product_id = '12345' { Update customer set member_flag2 = ' ' where customer_id = '123' } Probably needs to go in the loop where the check for notifications is done, which is probably in checkout_sucess.php. For more info on mysql & php syntax have a look at www.w3schools.com HTH G Thanks I'm new to coding from the database. Does this go in to the this code in checkout_success.php $global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'"); $global = tep_db_fetch_array($global_query); or $products_array = array(); $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name"); while ($products = tep_db_fetch_array($products_query)) { $products_array[] = array('id' => $products['products_id'], 'text' => $products['products_name']); And how do I code it in? Thanks
ecartsolutions Posted October 21, 2010 Posted October 21, 2010 Thanks I'm new to coding from the database. Does this go in to the this code in checkout_success.php $global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'"); $global = tep_db_fetch_array($global_query); or $products_array = array(); $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name"); while ($products = tep_db_fetch_array($products_query)) { $products_array[] = array('id' => $products['products_id'], 'text' => $products['products_name']); And how do I code it in? Thanks Insert the code after it.. if($products['products_id'] == '12345') { tep_db_query("update customer set member_flag2 = ' ' where customer_id = '123'"); } Hope that helps. PS:PHP is not hard to learn. there are 100s of tutorials online to get started :) Our truest life is when we are in dreams awake. -- Henry David Thoreau --
koollayed Posted October 22, 2010 Author Posted October 22, 2010 Insert the code after it.. if($products['products_id'] == '12345') { tep_db_query("update customer set member_flag2 = ' ' where customer_id = '123'"); } Hope that helps. PS:PHP is not hard to learn. there are 100s of tutorials online to get started :) Thanks for your help. The code I used for this is below $products_array = array(); $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name"); while ($products = tep_db_fetch_array($products_query)) { $products_array[] = array('id' => $products['products_id'], 'text' => $products['products_name']); Add if($products['products_id'] == '36') { tep_db_query("update customers set member_flag2 = '' where customers_id = '" . (int)$customer_id ."'"); For any newbies at php :) What I wonder is if I can pull the product (int) so I don't have to add a product id for every product any ideas?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.