Skip to main content

Posts

Remove all whitespaces from the entire column using MySQL Query

The below queries will remove all spaces, tabs characters, new line characters first and last space(s) from the table column. For replace all spaces :  UPDATE `table` SET `col_name` = REPLACE(`col_name`, ' ', '') For remove all tabs characters :  UPDATE `table` SET `col_name` = REPLACE(`col_name`, '\t', '' ) For remove all new line characters :  UPDATE `table` SET `col_name` = REPLACE(`col_name`, '\n', '') http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace For remove first and last space(s) of column :  UPDATE `table` SET `col_name` = TRIM(`col_name`) http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_trim

Get current filename with first parameter(Query String) from URL using PHP function

Today eabhyas come up with a Query String function. This function is useful to get the Query String from URL. This Function is used to get current filename with first parameter(Query String) from URL using PHP function . Function: function rns_QueryString_first($incomingURL){     preg_match('/[^&]+/', $incomingURL, $match);     return $outgoingURL = $match[0]; } Example: $path="property_add?id=3&aa=aa&b=123"; define('RNSFIFQ', rns_QueryString_first($path)); echo RNSFIFQ; Output: property_add?id=3

Remove Duplicate QueryStrings from URL using PHP

This simple PHP function is used to Remove Duplicate QueryStrings from URL. Function: function rnsQueryString_dupremov($qstring){     if(!empty($qstring)) {     $vars = explode('&', $qstring);     $final = array();     if(!empty($vars)) {         foreach($vars as $var) {             $parts = explode('=', $var);                 $key = $parts[0];             if(!empty($parts[1])) { $val = $parts[1]; } else {$val="";}                 if(!array_key_exists($key, $final) && !empty($val))                 $final[$key] = $val;         }     }     return http_build_query($final);     } else { return false; } } Example: $path="property_add.php?id=3&aa=aa&b=123&b=123&aa=aa"; define('RNSFIWQ', property_add.'?'.rnsQueryString_dupremov($_SERVER['QUERY_STRING']));  or define('RNSFIWQ', basename($_SERVER['SCRIPT_NAME'].'?'.rnsQueryString_dupremov($_SERVER['QUE