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? 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 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%'"; 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
Archived
This topic is now archived and is closed to further replies.