Latest Entries »

Check Domain Name Availability

Hi Guys to check the domain available or not and get it implement on PHP in your own site, you must use whois api.

1. Create a developer account on WHOIS.
2. The use following code to use in your PHP script

$contents = file_get_contents("http://www.whoisxmlapi.com//whoisserver/WhoisService?domainName=test.in&cmd=GET_DN_AVAILABILITY&username=username&password=password&outputFormat=JSON");
$contents = str_replace('\\', '', $contents);

$res=json_decode($contents);

$domainInfo = $res->DomainInfo;
if($domainInfo){
echo “Domain name: ” . print_r($domainInfo->domainName,1) .”
“;
echo “Domain Availability: ” .print_r($domainInfo->domainAvailability,1) .”
“;

//print_r($domainInfo);
}
?>

Try it…

ere we have a table named car and we want to calculate how many NULL values are there in ‘check’ and ‘flag’ fields

CREATE TABLE IF NOT EXISTS `car` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`brand` varchar(255) NOT NULL,
`check` int(1) DEFAULT NULL,
`flag` int(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;


– Dumping data for table `car`

INSERT INTO `car` (`id`, `brand`, `check`, `flag`) VALUES
(1, ‘Porsche’, NULL, 1),
(2, ‘Renault’, 1, NULL),
(3, ‘sadsa’, NULL, 1),
(4, ‘asdasd’, NULL, NULL);

Query run
————————–
select
sum(@chk:=if(ISNULL(`check`),0,@chk)+1) as CHKTOTAL,
sum(@flg:=if(ISNULL(`flag`),0,@flg)+1) as FLGTOTAL
FROM `car`

Returns
————————-
CHKTOTAL FLGTOTAL
3.000000 2.000000

How to move Dropdown Menu Over Flash Object

This is a general question always arises in my mind that how can I make my drop-down menu over a flash object. On designing I get two tricky things to set which make it possible.

1. Add wmode – transparent to your flash object.
2. Make z-index to max level in drop-down css.

e.g.
In your flash object set following

and
In css file of your top class set
z-index: 10000;

Thus, I come across the solution.

How to add new font to your website

Hi frnds I come across to add anew font file to my website, With a little research i meet with the solution as follows:

Step 1: Make a dir with name font and save the font files.

Step 2: In the css file add this as body font face.
Here I used font CronosPro font for my website

@font-face {
font-family: ‘Conv_CronosPro-Regular’;
src: url(‘../fonts/CronosPro-Regular.eot’);
src: local(‘?’), url(‘../fonts/CronosPro-Regular.woff’) format(‘woff’), url(‘../fonts/CronosPro-Regular.ttf’) format(‘truetype’), url(‘../fonts/CronosPro-Regular.svg’) format(‘svg’);
font-weight: normal;
font-style: normal;
font-size:12px;
}

Hope this help you out….

How to remove \n from a string in PHP

// Variable decleared
$foo =

this
is
a
block

“;
function nl2br_limit($string, $num){

$dirty = preg_replace(‘/\r/’, ”, $string);
$clean = preg_replace(‘/\n{4,}/’, str_repeat(“”, $num), preg_replace(‘/\n/’, ‘ ‘, $dirty));

return nl2br($clean);
}

echo nl2br_limit($foo,’4′);

Remove (4) if u want for all. enjoy :)

Ajax loading with Jquery

Hi Frnds,
I get come across a nice way to load Ajax response with Jquery

function sync_image(arg1,arg2,..)
{
if(confirm(“alert msg”))
{
$(“#ids_to_hide”).hide();
$(“#ids_to_show”).show();
var url = “file.php”; //file url to call
$.ajax({
type: “GET”,
url: url,
success: function(msg){
$(“#id_to_hide”).hide();
$(“#id_to_show”).show();

}
});
}
}

How to get last 10 working days

$i=1;
$fromdate = date(‘Y-m-d’);
//$todate = date(‘Y-m-d’);
$todate = date(‘Y-m-d’, mktime(0, 0, 0, date(“m”) , date(“d”)-1, date(“Y”)));
list($y, $m, $d) = split(“-”, $todate);
$weekends = array(‘Sunday’, ‘Saturday’);

$tenDateArray = array();
while($i<=10)
{
$day = date(‘l’, mktime(0, 0, 0, $m, $d, $y));
if(!in_array($day, $weekends))
{
$i++;
$tenDateArray[] = date(‘Y-m-d’, strtotime(‘-0 day’, strtotime($todate)));
}
$todate = date(‘Y-m-d’,strtotime(‘-1 day’, strtotime($todate)));
list($y, $m, $d) = split(“-”, $todate);
}
$to10date = $tenDateArray[max(array_keys($tenDateArray))];

Add working days

Hi, need to create a function which return week working days and also add (optional) if require :

function getAddDate($date,$day=0)
{
$dates = explode(“-”, $date);

$tomorrow = mktime(0, 0, 0, $dates[1] , $dates[2]+$day, $dates[0]);
$day = date(‘D’, $tomorrow);
if($day==’Sat’)
$day_inc = 3;
if($day==’Sun’)
$day_inc = 2;
return date(‘Y-m-d’, mktime(0, 0, 0, $dates[1] , $dates[2]+$day_inc, $dates[0]));
}

getAddDate(‘YYYY-mm-dd’,1);
It work out..

Jquery Input by Name

Hi here we simply explain how to use multiple input check-box as array to get value in java-script

put this in a loop

on the submit button :

now in the Javascript tags
function addfunc(arg1)
{
var field_name = $(“input:[name='field_name[]‘]”).serialize().replace(/%5B/g, ‘[').replace(/%5D/g, ']‘);
alert(field_name); //you get all values of selected checkbox as a string then you may use it in ur way
}

Hope this helpful for developers…

Testing website Install Jmeter

Hi I have get a chance to study the testing tools for website and found Jmeter as the most flexible and easy to installable and used tool.

To install Jmeter

1. Download Jmeter from http://jakarta.apache.org/jmeter/
For Windows download one of binary type and for linux use the source file.

2. The other is JRE get it from http://www.oracle.com/technetwork/java/javase/downloads/index.html

After this extract jmeter and run jmeter.bat in bin directory which runs the Jmeter java file.

Then read out the jmeter guide fromĀ http://www.roseindia.net/jmeter/using-jmeter.shtml

I just pleased and Jmeter help me alot.

Thanks…

Powered by WordPress. Theme: Motion by 85ideas.