Portman Posted February 23, 2019 Share Posted February 23, 2019 Hi, I'm trying to modify the admin/specials.php page so that i can update multiple different prices for different groups (think SPPC or Wholesale Lite) I am playing around with the update and insert section of the file... tep_db_query("insert into " . TABLE_SPECIALS . " (products_id, specials_new_products_price, specials_date_added, expires_date, status) values ('" . (int)$products_id . "', '" . tep_db_input($specials_price) . "', now(), " . (tep_not_null($expires_date) ? "'" . tep_db_input($expires_date) . "'" : 'null') . ", '1')"); tep_db_query("update " . TABLE_SPECIALS . " set specials_new_products_price = '" . tep_db_input($specials_price) . "', specials_last_modified = now(), expires_date = " . (tep_not_null($expires_date) ? "'" . tep_db_input($expires_date) . "'" : 'null') . " where specials_id = '" . (int)$specials_id . "'"); but I need to make a loop so that I can insert the multiple different prices.... In an attempt to get across what I want to do here is what my thought process is in a broken code kind of way... tep_db_query("insert into " . TABLE_SPECIALS . " (products_id, specials_new_products_price, ... for ($i=1; $i<=xxx; $i++) { insert_new_special_price_ . $i; } ... specials_date_added, expires_date, status) values ('" . (int)$products_id . "', '" . tep_db_input($specials_price) . "', now(), " . (tep_not_null($expires_date) ? "'" . tep_db_input($expires_date) . "'" : 'null') . ", '1')"); I have been trying different things and been looking around for solutions, but for the life of me I cant get it to work. Can anyone give me some help Link to comment Share on other sites More sharing options...
Portman Posted February 25, 2019 Author Share Posted February 25, 2019 Sorry, my above example does not make a lot of sense.... can I create 2 arrays... 1 with the table labels ... 1 with the record values and then add them to the tep_db_query line.... this sort of thing.... $array_labels = for ($i=1; $i<=xxx; $i++) { table_label_ . $i; } $array_values = for ($i=1; $i<=xxx; $i++) { insert_new_special_price_ . $i; } tep_db_query("insert into " . TABLE_SPECIALS . " (products_id, specials_new_products_price, . '" $array_labels "' . specials_date_added, expires_date, status) values ('" . (int)$products_id . "', '" . tep_db_input($specials_price) . "', '" . $array_values . "' ,now(), " . (tep_not_null($expires_date) ? "'" . tep_db_input($expires_date) . "'" : 'null') . ", '1')"); Link to comment Share on other sites More sharing options...
Dan Cole Posted February 25, 2019 Share Posted February 25, 2019 Pete have you looked at this add-on? https://apps.oscommerce.com/Gsxm9 Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here. Link to comment Share on other sites More sharing options...
Portman Posted February 26, 2019 Author Share Posted February 26, 2019 Thanks @Dan Cole I think that has done what I am hoping to do.... now to see if I can recreate it!! Link to comment Share on other sites More sharing options...
Portman Posted February 27, 2019 Author Share Posted February 27, 2019 Hi everyone... can someone please help me out with this one.... I'm trying to get this to work... for ($i=1; $i<=x; $i++) { $specials_new_ws_prices = ($sInfo->specials_new_ws_price_$i); echo $specials_new_ws_prices ; } obviously I get a "syntax error, unexpected '$i' (T_VARIABLE)" on the above... if I change it to; $specials_new_ws_prices = ($sInfo->specials_new_ws_price_1); It prints the correct value from the database, so how do I make it work using the value of $i The idea is to populate an input field in the loop. Thanks, Link to comment Share on other sites More sharing options...
Portman Posted February 27, 2019 Author Share Posted February 27, 2019 never mind.... sorted it out.... I assume this ok, or is there a better way to do it?... for ($i=1; $i<=x; $i++) { $temp_holder = "specials_new_ws_price_$i"; $specials_new_ws_prices = ($sInfo->$temp_holder); echo $specials_new_ws_prices; } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.