Thursday, December 6, 2012

Convert First letter a string to capital

Here is the function which is used to convert all the first letters of the name to capital Letters. 

 This idea of creating this  function is inspired with the words of my colleague   Kamal Relwani

Sunday, November 4, 2012

How to create a facebook add friend request

Using JavaScript :
 Things Required all u need to do i call
  1. Call FB.init Method -
    FB.init({  appId  : 'YOUR_APP_ID',  frictionlessRequests : true });
  2. To send request for purticular friends
    1. function sendRequestToRecipients(){ FB.ui ({method: 'apprequests', message: 'My Request', to: '12345,23456' }, requestCallback); }
  1.  To send request for all friends
    1. function sendRequestViaMultiFriendSelector() {
        FB.ui({method: 'apprequests',
          message: 'My  Request'
        }, callbackfunction());
      }
       callbackfunction(response){
       alert(response);
      }
  

Wednesday, October 3, 2012

Create a Date Drop down

Creating a Date year and Date drop down which is validated based on leap year and date 

Here is the code please add jquery script tag before you include the code


 function fnDate(){
try{
for(var i=1950;i<=2009;i++){
jq("#dobyy").append("<option value="+i+">"+i+"</option>");
}
for(var i=1;i<=12;i++){
jq("#dobmm").append("<option value="+i+">"+i+"</option>");
}

var month = '';
var year = '';
jq("#dobmm").change(function(){
month = jq("#dobmm").val();
year = jq("#dobyy").val();
var aOddMnth = ["1","3","5","7","8","10","12"];
var aEvnMnth = ["4","6","9","11"];
jq("#dobdd").html("<select name=\"dobdd\" id=\"dobdd\" title=\"1\" style=\"width:84px;\"><option value=\"\">Day</option></select>&nbsp;&nbsp;&nbsp;&nbsp;");
if(month > 0){
if(month == "2"){
if(year%4 == 0){
for(var i=1;i<=29;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}else{
for(var i=1;i<=28;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}
}
if(jq.inArray(month,aOddMnth) != -1){
for(var i=1;i<=31;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}
if(jq.inArray(month,aEvnMnth) != -1){
for(var i=1;i<=30;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}
}
});
}catch(e){
alert(e.message)
}
}

Sunday, April 1, 2012

A simple Shopping Cart code in PHP

Here is a simple way to code to code the shopping cart i have seen in many websites for the code but i hope i have done using basic simple concepts of PHP to code the Shopping cart

Here is the link to download the source code - download

Instructions for using that code
  1. Extract the ca.rar
  2. place ca folder in www folder
  3. Execute the backup file or use scripts present in dbscripts folder to create new tables
  4. Now run localhost/ca to execute the code 

 

Tuesday, March 27, 2012

Get Url From Browser in Php

Getting the URL  from the parent window when you use a popup. This small Example code might help you to get the url from the parent window this can be used normal windows also

 if(isset($_SERVER['HTTP_REFERER']))
{
   
    $strPrevScheme = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_SCHEME);
 
    $strPrevHost = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
 
    $strPrevPath = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH);
 
    $strPrevURL = urlencode($strPrevScheme.'://'.$strPrevHost.$strPrevPath);
   
   
}

the parse_url(url) gives the following array 

Array
(
    [scheme] => http
    [host] => hostname
    [user] => username
    [pass] => password
    [path] => /path
    [query] => arg=value
    [fragment] => anchor
)
 

 
reference - http://in2.php.net/manual/en/function.parse-url.php 

Monday, March 26, 2012

Finding the Count of all Charecters entered


<?php
/******************************************************************************
 * Filename: totalnumberofalphabets.php
 * Description: The file is used to count the number of occurences of each charecter
 * Author: G Jayendra Kartheek
 * Date Created: 26 Mar 2012
 * Copyright © 2012 All rights reserved
 ******************************************************************************/

//after user submits the values
if (isset($_POST['butSubmit']) && '' != $_POST['butSubmit']) {

    //taking the charecter into the array
    $strValue = str_split($_POST['txtInput']);
    //copying the string array
    $strDuplicate = $strValue;
   
    $iIntI = 0;
    //based on the string length travesing the array
    while ($iIntI < strlen($_POST['txtInput'])) {
        //initializing the count and j for every iteration
        $iCount = 0;
        $iIntIIntJ = 0;
        //comparing each and every element  and finding the count of each element
        while ($iIntIIntJ < strlen($_POST['txtInput'])) {
            if ($strDuplicate[$iIntI] == $strValue[$iIntIIntJ]) {

                $iCount++;
            }
            $iIntIIntJ++;
        }
        //printing the count
        echo '<br>Number of times "' . $strDuplicate[$iIntI] . '" repeated is : ' . $iCount;
        $iIntI++;
    }
}
?>
<form name="" method ="POST">
    <input type='text' name = 'txtInput'/><input type = 'submit' name= 'butSubmit' value ="OK"/>
</FORM>

Thursday, March 22, 2012

Closing the PopUp and redirecting Parent Window

I have tried for few hours to solve this problem Here is the simple example which helps you to solve the Problem

Problem:
 Create a PopUp window on submission of a value in PopUp the PopUp Closes and the Parent Windows redirects to Some other Page 

Solution:
Here is the simple way to solve it

Create 2 php pages

1. popup.php
Copy this Code

<html>
    <head>    
    </head>
    <body>
        <a href="#" onclick="window.open('popupcode.php','Login','height=500,width=420,scrollbars=yes');return false;">PopUp</a>
    </body>
    </html>




Tuesday, March 20, 2012

Count Number of tables in a Schema

This is a very Simple query to find the number of tables present in a purticular schema of the database


select information_schema as your default schema and use the following query to find the count of number of tables in a particular schema


SELECT count(*) FROM 'TABLES' WHERE TABLE_SCHEMA = 'YOUR_SCHEMA_NAME*'



*YOUR_SCHEMA_NAME = NAME OF THE SCHEMA TO WHICH YOU ARE FINDING THE COUNT







Switch Off Foreign Key Constraint

I used to use this code regularly but when i found it for the first time it took me to read many pages to read after getting the code i thought this would be useful for all people like me who want to Switch off the Foreign key Constraint in their tables

This is helpful when you are actually want to create tables irrespective of the Foreign key constraint 

To Turn Off - SET FOREIGN_KEY_CHECKS = 0;

To Turn On - SET FOREIGN_KEY_CHECKS = 1;


OAuth 2.0

Now its time to Switch on the easier and secured version of OAuth Protocol OAuth 2.0 so here is the presentation i have made which makes u people easy to understand the Protocol and important points to have talk to the server 


Presentation  - Download 




The presentation is based on the Oauth 2.0 written by the developers of Microsoft and Facebook on January 2012







Tuesday, March 13, 2012

Difference between Echo and Print in Php

We have Echo we have print in php which we use to display the output to the user
Both Echo and Print does the same work - Displaying the output on the screen
But there are couple of differences between them
Echo
  1. Output one or more strings
  2. Allows More parameters works only with the short open tags
  3. It is not a function
  4. It takes less memory

Print
  1. Output only one string
  2. It allows only one parameter
  3. Its not a real function but its a language construct
  4. It take a little more memory than echo



Tuesday, March 6, 2012

Train Seating Arrangement

I have refered many sites to get this searting arrangement this is almost common in all Indian Trains

Please click Download to get he seating arrangement

Friday, March 2, 2012

Curl Using PHP in a Gist

cURL: It is  a client that deals with URL so its named as cURL so as to say that it deals with URL only 

It is used to make client communicate with the server using command line 
arguments using cURL syntax

Its main use is to provide security to the URL's sent through the browser to the server
 
 The main commands in cURL  which i found is important are


1. curl_init() - with which the main curl operation starts

2.curl_setop($charecter,options,value)


                    $charecter = curl handle returned by curl_initi()


           options = curl provides various options with general syntax 

curlOPT_XXX 
                         other options are found in - PHP website

          value = value of the url

3. curl_exec() - which is used to execute a $charecter in which the information has be moved 

4.curl_close() - this is used to close the curl connection




          






Thursday, March 1, 2012

Connect With Facebook API in Simple 7 Steps

Here is the presentation or Document Where i have described Simple 7 Steps To Connect to Facebook this can be used to any Social Networking Site

Download the Presentation From this Link ---- Download











Simple Script to Share your site in different Social Networks

A simple Script used to share your Website on Different Social Networks Replace your Wesite in the my Blog URL Place


Wednesday, February 29, 2012

OAuth Protocol

Implementation of OAuth protocol 
Information of OAuth protocol in a gist 

Clearly explained in the Following Presentation

PPT - Link

Document - Link

Friday, February 24, 2012

Crop Image Using GD library in Php

I have tried image cropping using image copying GD Image function i have done it by using simple logic this program might be useful to all so i am posting it here because i have not used any jquery or any other language this is purely done in php
5 steps to use the code:
  1. Create a project in www folder
  2. paste the code present in link - Download
  3. create a folder named images
  4. Now run the folder