I am from Indonesia
help me, how to create logic of product code in accordance with the product name using script PHP?
example :
input product name : Toshiba Dynabook SS2000 Japan Product Notebook
then saved, product code become TDSJPN001
so that each combination of initial letters + three-digit number
Thanks.
[HELP ME] create product code using PHP??
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: [HELP ME] create product code using PHP??
You'll have to work out how you determine what the number is. If you already have the same product code that ends in 001, then you'll need to increment it, but I don't know where you have stored these:
Code: Select all
$name = 'Toshiba Dynabook SS2000 Japan Product Notebook';
$words = str_word_count($name, 1);
$code = '';
foreach($words as $word) {
$code .= $word[0];
}
$code .= sprintf('%03s', 1);mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
jaiswarvipin
- Forum Commoner
- Posts: 32
- Joined: Sat Sep 12, 2009 3:43 pm
- Location: India
Re: [HELP ME] create product code using PHP??
Hi,
adding to above you can use the following as well
above code only give you first Intilai of the String then not it's depending on your requriement .i.e. If you Number in sequeance then yo uneed to get any how the previuos number and if not then you can generate the random number of three degit usinf rand(3);
adding to above you can use the following as well
Code: Select all
$name = 'Toshiba Dynabook SS2000 Japan Product Notebook';
$nameArray = explode(" ",$name);
$name = "";
for($intCount = 0; $intCount < sizeof($nameArray) ; $intCount++)
$name . = substr($nameArray,0,1);Re: [HELP ME] create product code using PHP??
@jaiswarvipin and @AbraCadaver
I apologize because I'm less familiar with PHP
so please guide?
I apologize because I'm less familiar with PHP
so please guide?