<? PHP
$ Mysql_server_name = 'localhost ';
$ Mysql_username = 'root ';
$ Mysql_password = '';
$ Mysql_database = 'hairleft ';
$ Conn = mysql_connect ($ mysql_server_name,
$ Mysql_username, $ mysql_password,
$ Mysql_database );
$ Arr1 = array ("AA", "BBB", "CCC", "DDD", "eeee", "fff", "GG", "hhhh ", "III", "JJ", "KKKK", "lll", "mmm", "nnn ");
$ Arr2 = array ("oooo", "PPP", "qqqq", "Rrrr", "Sss ");
// $ Arr3 = array ("wqwq", "Sasa", "xzxz", "vcvc", "bvbv", "nbnb", "mnmn", "hghg ");
$ SQL = "insert into tag (name, status, first_customer_id, first_store_id, title) values ('test11', 1, 0, 0, 'test11 ')";
$ I = 1;
// Foreach ($ arr3 as $ ar3 ){
Foreach ($ arr1 as $ AR1 ){
Foreach ($ arr2 as $ AR2 ){
$ QQ = "2". $ ar1. "". $ AR2;
$ I ++;
// Echo $ QQ. $ I;
$ SQL. = ", ('". $ QQ. "', 1, 0, 0, '". $ QQ ."')";
// Tag_id name status first_customer_id first_store_id description titlecontent title
}
}
Mysql_select_db ($ mysql_database, $ conn );
$ Result = mysql_query ($ SQL );
// Echo $ SQL;
// Mysql_close ($ conn );
// Echo "Chenggong ";
$ SQL = "select * From tag where tag_id = (select max (tag_id) from tag )";
$ Result = mysql_query ($ SQL );
While ($ tagmaxids = mysql_fetch_array ($ result )){
$ Tagmaxid = $ tagmaxids ['tag _ id'];
// Echo $ tagmaxid;
}
$ SQL = "select * From tag_relation where tag_id = (select max (tag_id) from tag_relation )";
$ Result = mysql_query ($ SQL );
While ($ tagmaxids = mysql_fetch_array ($ result )){
$ Tagrelationmaxid = $ tagmaxids ['tag _ id'];
// Echo $ tagmaxid;
}
Echo $ tagmaxid. "<br/> ";
Echo $ tagrelationmaxid. "<br/> ";
If ($ tagrelationmaxid = ""){
$ Tagrelationmaxid = 1;
}
For ($ I = $ tagrelationmaxid; $ I <= $ tagmaxid; $ I ++ ){
If ($ I <$ tagmaxid ){
$ SQL _tagid. = $ I .",";
} Else {
$ SQL _tagid. = $ I;
}
}
// Echo $ SQL _tagid;
$ SQL _tag = "select tag_id, name from tag where tag_id>". $ tagrelationmaxid. "And tag_id <". $ tagmaxid;
// Echo $ SQL _tag;
$ Result = mysql_query ($ SQL _tag );
// $ Tagid_name = mysql_fetch_array ($ result );
While ($ tagmaxids = mysql_fetch_array ($ result )){
$ Tag_name [] = $ tagmaxids;
// Echo $ tagmaxid;
}
Foreach ($ tag_name as $ Tadd ){
// Echo $ Tadd ['tag _ id']. $ Tadd ['name']. "<br/> ";
$ STR = $ Tadd ['name'];
$ Res = explode ("", $ Str );
$ Re0 = $ res [0];
$ RE1 = $ res [1];
$ Re2 = $ res [2];
$ SQL = "select * From catalog_product_entity_varchar where attribute_id = 96 and (value like '% ". $ re0. "% 'or value like' % ". $ re1. "% 'or value like' % ". $ re2. "% ') order by case when value like' % ". $ re0. "% ". $ re1. "% ". $ re2. "% 'then 0 when value like '% ". $ re0. "% ". $ re2. "% ". $ re1. "% 'then 1 when value like '% ". $ re1. "% ". $ re0. "% ". $ re2. "% 'then 2 when value like '% ". $ re2. "% ". $ re0. "% ". $ re1. "% 'then 3 when value like '% ". $ re1. "% ". $ re2. "% ". $ re0. "% 'then 4 when value like '% ". $ re2. "% ". $ re1. "% ". $ re0. "% 'then 5 when value like '% ". $ re0. "% 'and value like' % ". $ re1. "% 'then 6 when value like '% ". $ re0. "% 'and value like' % ". $ re2. "% 'then 7 when value like '% ". $ re1. "% 'and value like' % ". $ re2. "% 'then 8 when value like '% ". $ re0. "% 'then 9 when value like '% ". $ re1. "% 'then 10 when value like '% ". $ re2. "% 'then 11 end ";
$ Result = mysql_query ($ SQL );
// Echo $ SQL;
$ I = 1;
$ STRs = "";
While ($ product_coll = mysql_fetch_array ($ result )){
If ($ I = 1 ){
$ STRs. = "('". $ Tadd ['tag _ id']. "','". $ product_coll ['entity _ id']. "', 1, 1 )";
} Else {
$ STRs. = ",('". $ Tadd ['tag _ id']. "','". $ product_coll ['entity _ id']. "', 1, 1 )";
}
// Echo $ SQL;
$ I ++;
}
$ STRs = "insert into tag_relation (tag_id, product_id, store_id, active) values". $ STRs;
$ Result = mysql_query ($ STRs );
// Echo "######";
// Echo $ STRs;
//*/
}
Echo "good ";
/*
Tag_id product_id store_id active
Select *
From counterss
Order by case
When car like '% Zhao % Qi % Yong %'
Then 0
When car like '% Zhao % Yong % Qi %'
Then 1
When car like '% Yong % Zhao % Qi %'
Then 2
When car like '% Qi % Zhao % Yong %'
Then 3
When car like '% Yong % Qi % zhao'
Then 4
When car like '% Qi % Yong % Zhao %'
Then 5
When car like '% Zhao %'
And car like '% Qi %'
Then 6
When car like '% Zhao %'
And car like '% Yong %'
Then 7
When car like '% Yong %'
And car like '% Qi %'
Then 8
When car like '% Yong %'
Then 9
When car like '% Qi %'
Then 10
When car like '% Zhao %'
Then 11
End
Limit 0, 30
End
Select *
From counterss
Order by case when car like '% AO Qi Y %'
Then 0
When car like '% Qi Y %'
Then 1
End
*/
?>