Examples

——————————————————————————-
Jatinder Singh | Create Your Badge

——————————————————————————-
SELECT max(id) from rs_category where id not in (SELECT max(id) from rs_category)

to find nth highest record:
(select distinct(salary) from employee order by salary desc limit n-1,1 n->find the nth largest)
——————————————————————————-
<!–?php

$s = “This is a test string”;

$url = “urlencode.php?data=” . urlencode($s);
print “Click me
“;
if (isset($_REQUEST[“data”])) {
print “URL: ” . $_SERVER[‘REQUEST_URI’] . ”
“;
print “Decoded data: ” . urldecode($_REQUEST[“data”]);
}

?>
Output:
Click me
URL: /samples/strings/urlencode.php?data=This+is+a+test+string
Decoded data: This is a test string
Explanation:

urlencode() is used to create a URL for a link. When the user clicks the link the page is reloaded with a string sent in the URL. The data in the URL is decoded and printed.
————————————————————————————–
http://maps.google.com/maps?q=Rohini,+New+Delhi,+Delhi,+India&hl=en&ll=28.732023,77.110256&spn=0.001239,0.003664&sll=37.0625,-95.677068&sspn=36.642161,86.572266&t=h&z=19

http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=Rohini,+New+Delhi,+Delhi,+India&aq=0&sll=37.0625,-95.677068&sspn=36.642161,86.572266&ie=UTF8&hq=&hnear=Rohini,+New+Delhi,+Delhi,+India&ll=28.731979,77.110347&spn=0.001239,0.003664&t=h&z=14&output=embed
View Larger Map
—————————————————–
Echo can accept multiple expressions while print cannot. With respect to performance echo is faster than print since it does not return a value. Print returns 1 or 0 depending on the success.
——————————————————
strtoupper($new_name) //ASHOK
—————————————–
——————————————————- ————-
to generate random numbers like captcha
//To Pull 7 Unique Random Values Out Of AlphaNumeric
//removed number 0, capital o, number 1 and small L
//Total: keys = 32, elements = 33
$characters = array(
” A “,” B “,” C “,” D “,” E “,” F “,” G “,” H “,” J “,” K “,” L “,” M “,” N “,” P “,” Q “,” R “,” T “,” U “,” V “,” W “,” X “,” Y “,” Z “,
” 1 “,” 2 “,” 3 “,” 4 “,” 6 “,” 7 “,” 8 “,” 9 “);

//make an “empty container” or array for our keys
$keys = array();

//first count of $keys is empty so “1”, remaining count is 1-6 = total 7 times
while(count($keys) < 7) {
//”0″ because we use this to FIND ARRAY KEYS which has a 0 value
//”-1″ because were only concerned of number of keys which is 32 not 33
//count($characters) = 33
$x = mt_rand(0, count($characters)-1);
if(!in_array($x, $keys)) {
$keys[] = $x;
}
}

foreach($keys as $key){
$random_chars .= $characters[$key];
}
//$random_chars=strtolower($random_chars);
echo $random_chars;
echo ‘
‘;
echo str_replace(‘ ‘,”,$random_chars);
echo ‘
‘;
//——————————————————————–
$date1 = “1982-01-10”; // y m d
$date2 = “2011-03-28”;

$diff = abs(strtotime($date2) – strtotime($date1));

$years = floor($diff / (365*60*60*24));
$months = floor(($diff – $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff – $years * 365*60*60*24 – $months*30*60*60*24)/ (60*60*24));

printf(“%d years, %d months, %d days\n”, $years, $months, $days);
//——————————
http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fmorgantravel.co.uk%2F
—————————————-

—————————————————

http://free.timeanddate.com/clock/i2mlfhfh/n176/szw110/szh110/hoc000/hbw2/hfceee/cf100/hncccc/fdi76/mqc000/mql10/mqw4/mqd98/mhc000/mhl10/mhw4/mhd98/mmc000/mml10/mmw1/mmd98
————————

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s