mysql having count(*) (Miracle )

$$having =" GROUP BY p.ID  having count(*) >=".(count($_REQUEST["DD"])-1)." ";

14/01/2015

jQuery Right click ContextMenu Plugin

jQuery ContextMenu Plugin http://www.javascripttoolbox.com/lib/contextmenu/   <script language="javascript" type="text/javascript"> $(document).on("contextmenu", "body", function(e){ alert("COPYRIGHT "); return false; }); </script>

										

14/01/2015

Codeigniter Sending Email With smtp using google gmail smtp

Codeigniter Sending Email With smtp [php] function index() { $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'my mail', 'smtp_pass' => 'my password', 'mailtype' => 'html', 'charset' => 'iso-8859-1' ); $this->load->library('email', $config); $this->email->set_newline("\r\n"); <!--more--> $this->email->from('aaa@gmail.com', 'aaa'); $this->email->to('bbb@gmail.com'); $this->email->subject('This is an email test'); $this->email->message('It is working. Great!'); $result = $this->email->send(); echo $this->email->print_debugger(); } [/php] Sending Email in a loop [php] $list =array( "my name 1"=>"example1@example.dd", "my name2"=>"example2@example.dd", "my name 3"=>"example3@example.dd" ); foreach ($list as $name => $address) { $this->email->clear(); $this->email->to($address); $this->email->from('your@example.com'); $this->email->subject('Here is your info '.$name); $this->email->message('Hi '.$name.' Here is the info you requested.'); $this->email->send(); } [/php]

14/01/2015

codeigniter customizing pagination


$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$config['cur_tag_open'] = '<b>';
$config['cur_tag_close'] = '</b>';
$config['first_link'] = ' First';
$config['last_link'] = ' Last';
$config['last_tag_open'] = '<p>';
$config['last_tag_close'] = '</p>';
$config['next_link'] = '';
$config['next_tag_open'] = '<p id="nextbutton" style="padding-left:5px;">';
$config['next_tag_close'] = '</p>';
$config['prev_link'] = '';
$config['prev_tag_open'] = '<p id="prevbutton" style="padding-right:5px;">';
$config['prev_tag_close'] = '</p>';


14/01/2015

Enter key on html form submission

[php] <pre><script> function testfunction(){ document.Add.submit(); } </script></pre> <form action="" method="post" name="Add" id="Add"  enctype="multipart/form-data" onkeypress="if(Enter(event)==true){ return testfunction () }"> [/php] --------

14/01/2015

php implode multi dimentioanal array key

[php] $array = array( array( Title => "rose", Price => 1.25, Number => 15 ), array( Title => "daisy", Price => 0.75, Number => 25, ), array( Title => "orchid", Price => 1.15, Number => 7 ) ); $str=implode(',', array_map( function($subarr){return $subarr["Number"];},$array)); [/php] ootput : 15,25,7     -----

14/01/2015

php - html

  • nl2br — Inserts HTML line breaks before all newlines in a string
  • htmlspecialchars() - Convert special characters to HTML entities
  • htmlentities() - Convert all applicable characters to HTML entities
  • wordwrap() - Wraps a string to a given number of characters
http://www.php.net/manual/en/function.nl2br.php

14/01/2015

Euro foreign exchange reference rates in xml format

http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html#dev

14/01/2015

country.sql country code, number mysql sql

/**
  * Country names, continent names and ISO-3166 codes.
  *
  * @updated  2013-02-14
  * @link     http://www.geekality.net/?p=1182
  * @link     https://bitbucket.org/svish/iso-3166-country-codes
  */
CREATE TABLE IF NOT EXISTS `continents` (
  `code` CHAR(2) NOT NULL COMMENT 'Continent code',
  `name` VARCHAR(255),
  PRIMARY KEY (`code`)
) ENGINE=InnoDB;

INSERT INTO `continents` VALUES
  ('AF', 'Africa'),
  ('AS', 'Asia'),
  ('EU', 'Europe'),
  ('NA', 'North America'),
  ('SA', 'South America'),
  ('OC', 'Oceania'),
  ('AN', 'Antarctica');


CREATE TABLE IF NOT EXISTS `countries` (
  `code` CHAR(2) NOT NULL COMMENT 'Two-letter country code (ISO 3166-1 alpha-2)',
  `name` VARCHAR(255) NOT NULL COMMENT 'English country name',
  `full_name` VARCHAR(255) NOT NULL COMMENT 'Full English country name',
  `iso3` CHAR(3) NOT NULL COMMENT 'Three-letter country code (ISO 3166-1 alpha-3)',
  `number` SMALLINT(3) ZEROFILL NOT NULL COMMENT 'Three-digit country number (ISO 3166-1 numeric)',
  `continent_code` CHAR(2) NOT NULL,
  PRIMARY KEY (`code`),
  KEY `continent_code` (`continent_code`),
  CONSTRAINT `fk_countries_continents` FOREIGN KEY (`continent_code`) REFERENCES `continents` (`code`)
) ENGINE=InnoDB;

INSERT INTO `countries` (`code`, `continent_code`, `name`, `iso3`, `number`, `full_name`) VALUES
  ('AF', 'AS', "Afghanistan", 'AFG', '004', "Islamic Republic of Afghanistan"),
  ('AX', 'EU', "Åland Islands", 'ALA', '248', "Åland Islands"),
  ('AL', 'EU', "Albania", 'ALB', '008', "Republic of Albania"),
  ('DZ', 'AF', "Algeria", 'DZA', '012', "People's Democratic Republic of Algeria"),
  ('AS', 'OC', "American Samoa", 'ASM', '016', "American Samoa"),
  ('AD', 'EU', "Andorra", 'AND', '020', "Principality of Andorra"),
  ('AO', 'AF', "Angola", 'AGO', '024', "Republic of Angola"),
  ('AI', 'NA', "Anguilla", 'AIA', '660', "Anguilla"),
  ('AQ', 'AN', "Antarctica", 'ATA', '010', "Antarctica (the territory South of 60 deg S)"),
  ('AG', 'NA', "Antigua and Barbuda", 'ATG', '028', "Antigua and Barbuda"),
  ('AR', 'SA', "Argentina", 'ARG', '032', "Argentine Republic"),
  ('AM', 'AS', "Armenia", 'ARM', '051', "Republic of Armenia"),
  ('AW', 'NA', "Aruba", 'ABW', '533', "Aruba"),
  ('AU', 'OC', "Australia", 'AUS', '036', "Commonwealth of Australia"),
  ('AT', 'EU', "Austria", 'AUT', '040', "Republic of Austria"),
  ('AZ', 'AS', "Azerbaijan", 'AZE', '031', "Republic of Azerbaijan"),
  ('BS', 'NA', "Bahamas", 'BHS', '044', "Commonwealth of the Bahamas"),
  ('BH', 'AS', "Bahrain", 'BHR', '048', "Kingdom of Bahrain"),
  ('BD', 'AS', "Bangladesh", 'BGD', '050', "People's Republic of Bangladesh"),
  ('BB', 'NA', "Barbados", 'BRB', '052', "Barbados"),
  ('BY', 'EU', "Belarus", 'BLR', '112', "Republic of Belarus"),
  ('BE', 'EU', "Belgium", 'BEL', '056', "Kingdom of Belgium"),
  ('BZ', 'NA', "Belize", 'BLZ', '084', "Belize"),
  ('BJ', 'AF', "Benin", 'BEN', '204', "Republic of Benin"),
  ('BM', 'NA', "Bermuda", 'BMU', '060', "Bermuda"),
  ('BT', 'AS', "Bhutan", 'BTN', '064', "Kingdom of Bhutan"),
  ('BO', 'SA', "Bolivia", 'BOL', '068', "Plurinational State of Bolivia"),
  ('BQ', 'NA', "Bonaire, Sint Eustatius and Saba", 'BES', '535', "Bonaire, Sint Eustatius and Saba"),
  ('BA', 'EU', "Bosnia and Herzegovina", 'BIH', '070', "Bosnia and Herzegovina"),
  ('BW', 'AF', "Botswana", 'BWA', '072', "Republic of Botswana"),
  ('BV', 'AN', "Bouvet Island (Bouvetoya)", 'BVT', '074', "Bouvet Island (Bouvetoya)"),
  ('BR', 'SA', "Brazil", 'BRA', '076', "Federative Republic of Brazil"),
  ('IO', 'AS', "British Indian Ocean Territory (Chagos Archipelago)", 'IOT', '086', "British Indian Ocean Territory (Chagos Archipelago)"),
  ('VG', 'NA', "British Virgin Islands", 'VGB', '092', "British Virgin Islands"),
  ('BN', 'AS', "Brunei Darussalam", 'BRN', '096', "Brunei Darussalam"),
  ('BG', 'EU', "Bulgaria", 'BGR', '100', "Republic of Bulgaria"),
  ('BF', 'AF', "Burkina Faso", 'BFA', '854', "Burkina Faso"),
  ('BI', 'AF', "Burundi", 'BDI', '108', "Republic of Burundi"),
  ('KH', 'AS', "Cambodia", 'KHM', '116', "Kingdom of Cambodia"),
  ('CM', 'AF', "Cameroon", 'CMR', '120', "Republic of Cameroon"),
  ('CA', 'NA', "Canada", 'CAN', '124', "Canada"),
  ('CV', 'AF', "Cape Verde", 'CPV', '132', "Republic of Cape Verde"),
  ('KY', 'NA', "Cayman Islands", 'CYM', '136', "Cayman Islands"),
  ('CF', 'AF', "Central African Republic", 'CAF', '140', "Central African Republic"),
  ('TD', 'AF', "Chad", 'TCD', '148', "Republic of Chad"),
  ('CL', 'SA', "Chile", 'CHL', '152', "Republic of Chile"),
  ('CN', 'AS', "China", 'CHN', '156', "People's Republic of China"),
  ('CX', 'AS', "Christmas Island", 'CXR', '162', "Christmas Island"),
  ('CC', 'AS', "Cocos (Keeling) Islands", 'CCK', '166', "Cocos (Keeling) Islands"),
  ('CO', 'SA', "Colombia", 'COL', '170', "Republic of Colombia"),
  ('KM', 'AF', "Comoros", 'COM', '174', "Union of the Comoros"),
  ('CD', 'AF', "Congo", 'COD', '180', "Democratic Republic of the Congo"),
  ('CG', 'AF', "Congo", 'COG', '178', "Republic of the Congo"),
  ('CK', 'OC', "Cook Islands", 'COK', '184', "Cook Islands"),
  ('CR', 'NA', "Costa Rica", 'CRI', '188', "Republic of Costa Rica"),
  ('CI', 'AF', "Cote d'Ivoire", 'CIV', '384', "Republic of Cote d'Ivoire"),
  ('HR', 'EU', "Croatia", 'HRV', '191', "Republic of Croatia"),
  ('CU', 'NA', "Cuba", 'CUB', '192', "Republic of Cuba"),
  ('CW', 'NA', "Curaçao", 'CUW', '531', "Curaçao"),
  ('CY', 'AS', "Cyprus", 'CYP', '196', "Republic of Cyprus"),
  ('CZ', 'EU', "Czech Republic", 'CZE', '203', "Czech Republic"),
  ('DK', 'EU', "Denmark", 'DNK', '208', "Kingdom of Denmark"),
  ('DJ', 'AF', "Djibouti", 'DJI', '262', "Republic of Djibouti"),
  ('DM', 'NA', "Dominica", 'DMA', '212', "Commonwealth of Dominica"),
  ('DO', 'NA', "Dominican Republic", 'DOM', '214', "Dominican Republic"),
  ('EC', 'SA', "Ecuador", 'ECU', '218', "Republic of Ecuador"),
  ('EG', 'AF', "Egypt", 'EGY', '818', "Arab Republic of Egypt"),
  ('SV', 'NA', "El Salvador", 'SLV', '222', "Republic of El Salvador"),
  ('GQ', 'AF', "Equatorial Guinea", 'GNQ', '226', "Republic of Equatorial Guinea"),
  ('ER', 'AF', "Eritrea", 'ERI', '232', "State of Eritrea"),
  ('EE', 'EU', "Estonia", 'EST', '233', "Republic of Estonia"),
  ('ET', 'AF', "Ethiopia", 'ETH', '231', "Federal Democratic Republic of Ethiopia"),
  ('FO', 'EU', "Faroe Islands", 'FRO', '234', "Faroe Islands"),
  ('FK', 'SA', "Falkland Islands (Malvinas)", 'FLK', '238', "Falkland Islands (Malvinas)"),
  ('FJ', 'OC', "Fiji", 'FJI', '242', "Republic of Fiji"),
  ('FI', 'EU', "Finland", 'FIN', '246', "Republic of Finland"),
  ('FR', 'EU', "France", 'FRA', '250', "French Republic"),
  ('GF', 'SA', "French Guiana", 'GUF', '254', "French Guiana"),
  ('PF', 'OC', "French Polynesia", 'PYF', '258', "French Polynesia"),
  ('TF', 'AN', "French Southern Territories", 'ATF', '260', "French Southern Territories"),
  ('GA', 'AF', "Gabon", 'GAB', '266', "Gabonese Republic"),
  ('GM', 'AF', "Gambia", 'GMB', '270', "Republic of the Gambia"),
  ('GE', 'AS', "Georgia", 'GEO', '268', "Georgia"),
  ('DE', 'EU', "Germany", 'DEU', '276', "Federal Republic of Germany"),
  ('GH', 'AF', "Ghana", 'GHA', '288', "Republic of Ghana"),
  ('GI', 'EU', "Gibraltar", 'GIB', '292', "Gibraltar"),
  ('GR', 'EU', "Greece", 'GRC', '300', "Hellenic Republic Greece"),
  ('GL', 'NA', "Greenland", 'GRL', '304', "Greenland"),
  ('GD', 'NA', "Grenada", 'GRD', '308', "Grenada"),
  ('GP', 'NA', "Guadeloupe", 'GLP', '312', "Guadeloupe"),
  ('GU', 'OC', "Guam", 'GUM', '316', "Guam"),
  ('GT', 'NA', "Guatemala", 'GTM', '320', "Republic of Guatemala"),
  ('GG', 'EU', "Guernsey", 'GGY', '831', "Bailiwick of Guernsey"),
  ('GN', 'AF', "Guinea", 'GIN', '324', "Republic of Guinea"),
  ('GW', 'AF', "Guinea-Bissau", 'GNB', '624', "Republic of Guinea-Bissau"),
  ('GY', 'SA', "Guyana", 'GUY', '328', "Co-operative Republic of Guyana"),
  ('HT', 'NA', "Haiti", 'HTI', '332', "Republic of Haiti"),
  ('HM', 'AN', "Heard Island and McDonald Islands", 'HMD', '334', "Heard Island and McDonald Islands"),
  ('VA', 'EU', "Holy See (Vatican City State)", 'VAT', '336', "Holy See (Vatican City State)"),
  ('HN', 'NA', "Honduras", 'HND', '340', "Republic of Honduras"),
  ('HK', 'AS', "Hong Kong", 'HKG', '344', "Hong Kong Special Administrative Region of China"),
  ('HU', 'EU', "Hungary", 'HUN', '348', "Hungary"),
  ('IS', 'EU', "Iceland", 'ISL', '352', "Republic of Iceland"),
  ('IN', 'AS', "India", 'IND', '356', "Republic of India"),
  ('ID', 'AS', "Indonesia", 'IDN', '360', "Republic of Indonesia"),
  ('IR', 'AS', "Iran", 'IRN', '364', "Islamic Republic of Iran"),
  ('IQ', 'AS', "Iraq", 'IRQ', '368', "Republic of Iraq"),
  ('IE', 'EU', "Ireland", 'IRL', '372', "Ireland"),
  ('IM', 'EU', "Isle of Man", 'IMN', '833', "Isle of Man"),
  ('IL', 'AS', "Israel", 'ISR', '376', "State of Israel"),
  ('IT', 'EU', "Italy", 'ITA', '380', "Italian Republic"),
  ('JM', 'NA', "Jamaica", 'JAM', '388', "Jamaica"),
  ('JP', 'AS', "Japan", 'JPN', '392', "Japan"),
  ('JE', 'EU', "Jersey", 'JEY', '832', "Bailiwick of Jersey"),
  ('JO', 'AS', "Jordan", 'JOR', '400', "Hashemite Kingdom of Jordan"),
  ('KZ', 'AS', "Kazakhstan", 'KAZ', '398', "Republic of Kazakhstan"),
  ('KE', 'AF', "Kenya", 'KEN', '404', "Republic of Kenya"),
  ('KI', 'OC', "Kiribati", 'KIR', '296', "Republic of Kiribati"),
  ('KP', 'AS', "Korea", 'PRK', '408', "Democratic People's Republic of Korea"),
  ('KR', 'AS', "Korea", 'KOR', '410', "Republic of Korea"),
  ('KW', 'AS', "Kuwait", 'KWT', '414', "State of Kuwait"),
  ('KG', 'AS', "Kyrgyz Republic", 'KGZ', '417', "Kyrgyz Republic"),
  ('LA', 'AS', "Lao People's Democratic Republic", 'LAO', '418', "Lao People's Democratic Republic"),
  ('LV', 'EU', "Latvia", 'LVA', '428', "Republic of Latvia"),
  ('LB', 'AS', "Lebanon", 'LBN', '422', "Lebanese Republic"),
  ('LS', 'AF', "Lesotho", 'LSO', '426', "Kingdom of Lesotho"),
  ('LR', 'AF', "Liberia", 'LBR', '430', "Republic of Liberia"),
  ('LY', 'AF', "Libya", 'LBY', '434', "Libya"),
  ('LI', 'EU', "Liechtenstein", 'LIE', '438', "Principality of Liechtenstein"),
  ('LT', 'EU', "Lithuania", 'LTU', '440', "Republic of Lithuania"),
  ('LU', 'EU', "Luxembourg", 'LUX', '442', "Grand Duchy of Luxembourg"),
  ('MO', 'AS', "Macao", 'MAC', '446', "Macao Special Administrative Region of China"),
  ('MK', 'EU', "Macedonia", 'MKD', '807', "Republic of Macedonia"),
  ('MG', 'AF', "Madagascar", 'MDG', '450', "Republic of Madagascar"),
  ('MW', 'AF', "Malawi", 'MWI', '454', "Republic of Malawi"),
  ('MY', 'AS', "Malaysia", 'MYS', '458', "Malaysia"),
  ('MV', 'AS', "Maldives", 'MDV', '462', "Republic of Maldives"),
  ('ML', 'AF', "Mali", 'MLI', '466', "Republic of Mali"),
  ('MT', 'EU', "Malta", 'MLT', '470', "Republic of Malta"),
  ('MH', 'OC', "Marshall Islands", 'MHL', '584', "Republic of the Marshall Islands"),
  ('MQ', 'NA', "Martinique", 'MTQ', '474', "Martinique"),
  ('MR', 'AF', "Mauritania", 'MRT', '478', "Islamic Republic of Mauritania"),
  ('MU', 'AF', "Mauritius", 'MUS', '480', "Republic of Mauritius"),
  ('YT', 'AF', "Mayotte", 'MYT', '175', "Mayotte"),
  ('MX', 'NA', "Mexico", 'MEX', '484', "United Mexican States"),
  ('FM', 'OC', "Micronesia", 'FSM', '583', "Federated States of Micronesia"),
  ('MD', 'EU', "Moldova", 'MDA', '498', "Republic of Moldova"),
  ('MC', 'EU', "Monaco", 'MCO', '492', "Principality of Monaco"),
  ('MN', 'AS', "Mongolia", 'MNG', '496', "Mongolia"),
  ('ME', 'EU', "Montenegro", 'MNE', '499', "Montenegro"),
  ('MS', 'NA', "Montserrat", 'MSR', '500', "Montserrat"),
  ('MA', 'AF', "Morocco", 'MAR', '504', "Kingdom of Morocco"),
  ('MZ', 'AF', "Mozambique", 'MOZ', '508', "Republic of Mozambique"),
  ('MM', 'AS', "Myanmar", 'MMR', '104', "Republic of the Union of Myanmar"),
  ('NA', 'AF', "Namibia", 'NAM', '516', "Republic of Namibia"),
  ('NR', 'OC', "Nauru", 'NRU', '520', "Republic of Nauru"),
  ('NP', 'AS', "Nepal", 'NPL', '524', "Federal Democratic Republic of Nepal"),
  ('NL', 'EU', "Netherlands", 'NLD', '528', "Kingdom of the Netherlands"),
  ('NC', 'OC', "New Caledonia", 'NCL', '540', "New Caledonia"),
  ('NZ', 'OC', "New Zealand", 'NZL', '554', "New Zealand"),
  ('NI', 'NA', "Nicaragua", 'NIC', '558', "Republic of Nicaragua"),
  ('NE', 'AF', "Niger", 'NER', '562', "Republic of Niger"),
  ('NG', 'AF', "Nigeria", 'NGA', '566', "Federal Republic of Nigeria"),
  ('NU', 'OC', "Niue", 'NIU', '570', "Niue"),
  ('NF', 'OC', "Norfolk Island", 'NFK', '574', "Norfolk Island"),
  ('MP', 'OC', "Northern Mariana Islands", 'MNP', '580', "Commonwealth of the Northern Mariana Islands"),
  ('NO', 'EU', "Norway", 'NOR', '578', "Kingdom of Norway"),
  ('OM', 'AS', "Oman", 'OMN', '512', "Sultanate of Oman"),
  ('PK', 'AS', "Pakistan", 'PAK', '586', "Islamic Republic of Pakistan"),
  ('PW', 'OC', "Palau", 'PLW', '585', "Republic of Palau"),
  ('PS', 'AS', "Palestine", 'PSE', '275', "State of Palestine"),
  ('PA', 'NA', "Panama", 'PAN', '591', "Republic of Panama"),
  ('PG', 'OC', "Papua New Guinea", 'PNG', '598', "Independent State of Papua New Guinea"),
  ('PY', 'SA', "Paraguay", 'PRY', '600', "Republic of Paraguay"),
  ('PE', 'SA', "Peru", 'PER', '604', "Republic of Peru"),
  ('PH', 'AS', "Philippines", 'PHL', '608', "Republic of the Philippines"),
  ('PN', 'OC', "Pitcairn Islands", 'PCN', '612', "Pitcairn Islands"),
  ('PL', 'EU', "Poland", 'POL', '616', "Republic of Poland"),
  ('PT', 'EU', "Portugal", 'PRT', '620', "Portuguese Republic"),
  ('PR', 'NA', "Puerto Rico", 'PRI', '630', "Commonwealth of Puerto Rico"),
  ('QA', 'AS', "Qatar", 'QAT', '634', "State of Qatar"),
  ('RE', 'AF', "Réunion", 'REU', '638', "Réunion"),
  ('RO', 'EU', "Romania", 'ROU', '642', "Romania"),
  ('RU', 'EU', "Russian Federation", 'RUS', '643', "Russian Federation"),
  ('RW', 'AF', "Rwanda", 'RWA', '646', "Republic of Rwanda"),
  ('BL', 'NA', "Saint Barthélemy", 'BLM', '652', "Saint Barthélemy"),
  ('SH', 'AF', "Saint Helena, Ascension and Tristan da Cunha", 'SHN', '654', "Saint Helena, Ascension and Tristan da Cunha"),
  ('KN', 'NA', "Saint Kitts and Nevis", 'KNA', '659', "Federation of Saint Kitts and Nevis"),
  ('LC', 'NA', "Saint Lucia", 'LCA', '662', "Saint Lucia"),
  ('MF', 'NA', "Saint Martin", 'MAF', '663', "Saint Martin (French part)"),
  ('PM', 'NA', "Saint Pierre and Miquelon", 'SPM', '666', "Saint Pierre and Miquelon"),
  ('VC', 'NA', "Saint Vincent and the Grenadines", 'VCT', '670', "Saint Vincent and the Grenadines"),
  ('WS', 'OC', "Samoa", 'WSM', '882', "Independent State of Samoa"),
  ('SM', 'EU', "San Marino", 'SMR', '674', "Republic of San Marino"),
  ('ST', 'AF', "Sao Tome and Principe", 'STP', '678', "Democratic Republic of Sao Tome and Principe"),
  ('SA', 'AS', "Saudi Arabia", 'SAU', '682', "Kingdom of Saudi Arabia"),
  ('SN', 'AF', "Senegal", 'SEN', '686', "Republic of Senegal"),
  ('RS', 'EU', "Serbia", 'SRB', '688', "Republic of Serbia"),
  ('SC', 'AF', "Seychelles", 'SYC', '690', "Republic of Seychelles"),
  ('SL', 'AF', "Sierra Leone", 'SLE', '694', "Republic of Sierra Leone"),
  ('SG', 'AS', "Singapore", 'SGP', '702', "Republic of Singapore"),
  ('SX', 'NA', "Sint Maarten (Dutch part)", 'SXM', '534', "Sint Maarten (Dutch part)"),
  ('SK', 'EU', "Slovakia (Slovak Republic)", 'SVK', '703', "Slovakia (Slovak Republic)"),
  ('SI', 'EU', "Slovenia", 'SVN', '705', "Republic of Slovenia"),
  ('SB', 'OC', "Solomon Islands", 'SLB', '090', "Solomon Islands"),
  ('SO', 'AF', "Somalia", 'SOM', '706', "Somali Republic"),
  ('ZA', 'AF', "South Africa", 'ZAF', '710', "Republic of South Africa"),
  ('GS', 'AN', "South Georgia and the South Sandwich Islands", 'SGS', '239', "South Georgia and the South Sandwich Islands"),
  ('SS', 'AF', "South Sudan", 'SSD', '728', "Republic of South Sudan"),
  ('ES', 'EU', "Spain", 'ESP', '724', "Kingdom of Spain"),
  ('LK', 'AS', "Sri Lanka", 'LKA', '144', "Democratic Socialist Republic of Sri Lanka"),
  ('SD', 'AF', "Sudan", 'SDN', '729', "Republic of Sudan"),
  ('SR', 'SA', "Suriname", 'SUR', '740', "Republic of Suriname"),
  ('SJ', 'EU', "Svalbard & Jan Mayen Islands", 'SJM', '744', "Svalbard & Jan Mayen Islands"),
  ('SZ', 'AF', "Swaziland", 'SWZ', '748', "Kingdom of Swaziland"),
  ('SE', 'EU', "Sweden", 'SWE', '752', "Kingdom of Sweden"),
  ('CH', 'EU', "Switzerland", 'CHE', '756', "Swiss Confederation"),
  ('SY', 'AS', "Syrian Arab Republic", 'SYR', '760', "Syrian Arab Republic"),
  ('TW', 'AS', "Taiwan", 'TWN', '158', "Taiwan, Province of China"),
  ('TJ', 'AS', "Tajikistan", 'TJK', '762', "Republic of Tajikistan"),
  ('TZ', 'AF', "Tanzania", 'TZA', '834', "United Republic of Tanzania"),
  ('TH', 'AS', "Thailand", 'THA', '764', "Kingdom of Thailand"),
  ('TL', 'AS', "Timor-Leste", 'TLS', '626', "Democratic Republic of Timor-Leste"),
  ('TG', 'AF', "Togo", 'TGO', '768', "Togolese Republic"),
  ('TK', 'OC', "Tokelau", 'TKL', '772', "Tokelau"),
  ('TO', 'OC', "Tonga", 'TON', '776', "Kingdom of Tonga"),
  ('TT', 'NA', "Trinidad and Tobago", 'TTO', '780', "Republic of Trinidad and Tobago"),
  ('TN', 'AF', "Tunisia", 'TUN', '788', "Tunisian Republic"),
  ('TR', 'AS', "Turkey", 'TUR', '792', "Republic of Turkey"),
  ('TM', 'AS', "Turkmenistan", 'TKM', '795', "Turkmenistan"),
  ('TC', 'NA', "Turks and Caicos Islands", 'TCA', '796', "Turks and Caicos Islands"),
  ('TV', 'OC', "Tuvalu", 'TUV', '798', "Tuvalu"),
  ('UG', 'AF', "Uganda", 'UGA', '800', "Republic of Uganda"),
  ('UA', 'EU', "Ukraine", 'UKR', '804', "Ukraine"),
  ('AE', 'AS', "United Arab Emirates", 'ARE', '784', "United Arab Emirates"),
  ('GB', 'EU', "United Kingdom of Great Britain & Northern Ireland", 'GBR', '826', "United Kingdom of Great Britain & Northern Ireland"),
  ('US', 'NA', "United States of America", 'USA', '840', "United States of America"),
  ('UM', 'OC', "United States Minor Outlying Islands", 'UMI', '581', "United States Minor Outlying Islands"),
  ('VI', 'NA', "United States Virgin Islands", 'VIR', '850', "United States Virgin Islands"),
  ('UY', 'SA', "Uruguay", 'URY', '858', "Eastern Republic of Uruguay"),
  ('UZ', 'AS', "Uzbekistan", 'UZB', '860', "Republic of Uzbekistan"),
  ('VU', 'OC', "Vanuatu", 'VUT', '548', "Republic of Vanuatu"),
  ('VE', 'SA', "Venezuela", 'VEN', '862', "Bolivarian Republic of Venezuela"),
  ('VN', 'AS', "Vietnam", 'VNM', '704', "Socialist Republic of Vietnam"),
  ('WF', 'OC', "Wallis and Futuna", 'WLF', '876', "Wallis and Futuna"),
  ('EH', 'AF', "Western Sahara", 'ESH', '732', "Western Sahara"),
  ('YE', 'AS', "Yemen", 'YEM', '887', "Yemen"),
  ('ZM', 'AF', "Zambia", 'ZMB', '894', "Republic of Zambia"),
  ('ZW', 'AF', "Zimbabwe", 'ZWE', '716', "Republic of Zimbabwe");
https://bitbucket.org/svish/iso-3166-country-codes/src/56b0436f894b/countries.sql?at=default

14/01/2015

jQuery Validation Engine

http://www.position-relative.net/creation/formValidator/demos/demoValidators.html#

jQuery.validationEngine

Demos

Documentation

Github

Authors

Copyright(c) 2010, Cedric Dugas http://www.position-absolute.com 2.0 Rewrite by Olivier Refalo http://www.crionics.com

14/01/2015

Magic Constants

Name Description
__LINE__ The current line number of the file.
__FILE__ The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path with symlinks resolved whereas in older versions it contained relative path under some circumstances.
__DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory. (Added in PHP 5.3.0.)
__FUNCTION__ The function name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the function name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
__CLASS__ The class name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased. The class name includes the namespace it was declared in (e.g. Foo\Bar). Note that as of PHP 5.4 __CLASS__ works also in traits. When used in a trait method, __CLASS__ is the name of the class the trait is used in.
__TRAIT__ The trait name. (Added in PHP 5.4.0) As of PHP 5.4 this constant returns the trait as it was declared (case-sensitive). The trait name includes the namespace it was declared in (e.g. Foo\Bar).
__METHOD__ The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive).
__NAMESPACE__ The name of the current namespace (case-sensitive). This constant is defined in compile-time (Added in PHP 5.3.0).
http://php.net/manual/en/language.constants.predefined.php

14/01/2015

php class list

get_class — Returns the name of the class of an object get_parent_class — Retrieves the parent class name for object or class is_subclass_of — Checks if the object has this class as one of its parents
get_class_vars — Get the default properties of the class get_object_vars — Gets the properties of the given object property_exists — Checks if the object or class has a property

14/01/2015

xml Entity escaping code

Entity escaping Your Sitemap file must be UTF-8 encoded (you can generally do this when you save the file). As with all XML files, any data values (including URLs) must use entity escape codes for the characters listed in the table below. Character Escape Code Ampersand      :     &       &amp; Single Quote    :     '         &apos; Double Quote  :     "         &quot; Greater Than   :     >        &gt; Less Than        :     <        &lt; In addition, all URLs (including the URL of your Sitemap) must be URL-escaped and encoded for readability by the web server on which they are located. However, if you are using any sort of script, tool, or log file to generate your URLs (anything except typing them in by hand), this is usually already done for you. Please check to make sure that your URLs follow the RFC-3986 standard for URIs, the RFC-3987 standard for IRIs, and the XML standard. Below is an example of a URL that uses a non-ASCII character (ü), as well as a character that requires entity escaping (&): http://www.example.com/ümlat.php&q=name Below is that same URL, ISO-8859-1 encoded (for hosting on a server that uses that encoding) and URL escaped: http://www.example.com/%FCmlat.php&q=name Below is that same URL, UTF-8 encoded (for hosting on a server that uses that encoding) and URL escaped: http://www.example.com/%C3%BCmlat.php&q=name Below is that same URL, but also entity escaped: http://www.example.com/%C3%BCmlat.php&amp;q=name   [php] <pre><code>function xml_entities($string) { return strtr( $string, array( "<" => "&lt;", ">" => "&gt;", '"' => "&quot;", "'" => "&apos;", "&" => "&amp;", ) ); } [/php]

14/01/2015

loading a page effect

[php] <style type="text/css" id="page-css"> #loading { z-index:1000; position:absolute; width:100%; height:100%; overflow:hidden; background-color:#fff;} #loading .middle { position:absolute; width:100%; margin-top: -24px; top: 50%; height:52px; text-align:center;} #loadingBg { position:absolute; width:100%; height:100%; overflow:hidden; background-color:#fff; display:none;} #loadingBg .middle { position:absolute; width:100%; margin-top: -24px; top: 50%; height:52px; text-align:center;} </style> <script type="text/javascript" id="sourcecode"> window.onload = function() { $("#loading").delay(100).fadeOut(1000); } </script> <body> <div id="loading"> <div class="middle"> <div class="inner"> <img src="{RootDir}{TempDir}assets/css/img/yukleniyor.gif" alt="" /> </div> </div> </div> [/php]


14/01/2015

jQuery $ trim form value before submit

[php] $('form').submit(function(){ $(this).find('input:text').each(function(){ $(this).val($.trim($(this).val())); }); }); [/php]

14/01/2015

How to prevent form submission by pressing enter key

[php] <script language="javascript" type="text/JavaScript""> document.onkeypress = keyPress; var count = 1; function keyPress() { if (window.event.keyCode == 13) { event.returnValue=false; event.cancel = true; } } </script> [/php] OR [php] <body OnKeyPress="return disableKeyPress(event)"> <script language="JavaScript"> function disableEnterKey(e) { var key; if(window.event) key = window.event.keyCode; //IE else key = e.which; //firefox return (key != 13); } [/php] modified by muslum21 for jquery [php] $("body").keydown(function (e) { var key; if(window.event) key = window.event.keyCode; //IE else key = e.which; //firefox return (key != 13); }); </script> [/php] Here is a modified version of my function. It does the following: Prevents the enter key from working on any element of the form other than the textarea, button, submit. The enter key now acts like a tab. preventDefault(), stopPropagation() being invoked on the element is fine, but invoked on the form seems to stop the event from ever getting to the element. So my workaround is to check the element type, if the type is not a textarea (enters permitted), or button/submit (enter = click) then we just tab to the next thing. Invoking .next() on the element is not useful because the other elements might not be simple siblings, however since DOM pretty much garantees order when selecting so all is well. [php] function preventEnterSubmit(e) { if (e.which == 13) { var $targ = $(e.target); if (!$targ.is("textarea") && !$targ.is(":button,:submit")) { var focusNext = false; $(this).find(":input:visible:not([disabled],[readonly]), a").each(function(){ if (this === e.target) { focusNext = true; } else if (focusNext){ $(this).focus(); return false; } }); return false; } } } &nbsp; [/php] http://stackoverflow.com/questions/1563062/prevent-form-submission-with-enter-key

14/01/2015

javascript - trim functions

  [code] &nbsp; function ltrim(str) { for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++); return str.substring(k, str.length); } function rtrim(str) { for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ; return str.substring(0,j+1); } function trim(str) { return ltrim(rtrim(str)); } function isWhitespace(charToCheck) { var whitespaceChars = " \t\n\r\f"; return (whitespaceChars.indexOf(charToCheck) != -1); &nbsp; [/code]

14/01/2015

Php in_array_r function - check if an array exist in 2 dimentional array

in_array_r $needle, $2darray, 2 dimentional array  to be searched $uniqueKey   -----> $needle['ID'] [php] function in_array_r($needle, $2darray,$uniqueKey) { $found = false; foreach ($2darray as $item) { if ($item[$uniqueKey] == $needle[$uniqueKey]) { $found = true; break; } elseif (is_array($item)) { $found = in_array_r($needle, $item); if($found) { break; } } } return $found; } &nbsp; [/php]

14/01/2015

array sorting algoritm

[php] <?php function arrayUnique($array, $preserveKeys = false) { // Unique Array for return $arrayRewrite = array(); // Array with the md5 hashes $arrayHashes = array(); foreach($array as $key => $item) { // Serialize the current element and create a md5 hash $hash = md5(serialize($item)); // If the md5 didn't come up yet, add the element to // to arrayRewrite, otherwise drop it if (!isset($arrayHashes[$hash])) { // Save the current element hash $arrayHashes[$hash] = $hash; // Add element to the unique Array if ($preserveKeys) { $arrayRewrite[$key] = $item; } else { $arrayRewrite[] = $item; } } } return $arrayRewrite; } $input = array( array( 'id' => 123, 'ean' => '1234567890123' ), array( 'id' => 123, 'ean' => '4852950174938' ), array( 'id' => 123, 'ean' => '1234567890123' ), ); $input = arrayUnique($input); print_r($input); ?> [/php] 2 dimentional array sorting by key [php]</pre> function sortMultiArrayByKey($argArray, $argKey, $argOrder=SORT_ASC){ foreach ($argArray as $key => $row){ $key_arr[$key] = $row[$argKey]; } array_multisort($key_arr, $argOrder, $argArray); return $argArray; } <pre> output: <strong></strong> Array ( [0] => Array ( [id] => 123 [ean] => 1234567890123 ) [1] => Array ( [id] => 123 [ean] => 4852950174938 ) ) <strong></strong> [/php]

14/01/2015

PHP Directory Functions

  scandir — List files and directories inside the specified path ref : http://www.php.net/manual/en/function.scandir.php

14/01/2015

ImageWorkshop using php GD to manipulate images

PHP class using GD library to work easily with images as layers (like Photoshop or GIMP) http://phpimageworkshop.com/

14/01/2015