BillyMako Posted November 7, 2008 Share Posted November 7, 2008 In the product list online i have the same products uner different names due to restrictions on oscommerce. Example: VDE004-DE VDE004-DE1 VDE004-DE2 NLD6400-TO NLD6400-TO1 etc..... In the inventory list it will just have - VDE004 NLD6400 When a product is purchased is decrements one off the stock_level column. I need the code to say decrement 1 off the stock_level where the letters before a dash match the name in the inventory list. So WHERE "VDE004"-DE = VDE004; Can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/131723-need-to-match-product-with-letters-before-the-dash/ Share on other sites More sharing options...
ILMV Posted November 7, 2008 Share Posted November 7, 2008 Hello! $product = "VDE004-DE"; //Split the string down, based on our - delimiter $pieces= explode("-", $product ); // You only want piece 0 echo $pieces[0]; // VDE004 http://uk2.php.net/manual/en/function.explode.php Quote Link to comment https://forums.phpfreaks.com/topic/131723-need-to-match-product-with-letters-before-the-dash/#findComment-684220 Share on other sites More sharing options...
.josh Posted November 7, 2008 Share Posted November 7, 2008 Okay I am assuming that you already have for instance VDE004 in a variable (let's say $id for example), since you're wanting to go from there, matching stuff up, right? $sql = "update tablename set stock_level = stock_level - 1 where product like '$id%'"; Quote Link to comment https://forums.phpfreaks.com/topic/131723-need-to-match-product-with-letters-before-the-dash/#findComment-684264 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.