Number System

Bit : A Bit is a value of either a 0 or 1.

Nibble : 1 Nibble = 4 Bits

Byte : 1 Byte = 8 Bits

Kilobyte (KB) : 1 KB = ( 8 * 1024 )8,192 Bits ,

Kilobyte (KB)1 KB = 1,024 Bytes
Megabyte (MB) 1MB =1024 KB
Gigabyte (GB) 1GB = 1024 MB
Terabyte (TB) 1TB = 1024 GB
Petabyte (PB) 1PB = 1024 TB
Exabyte (EB) 1EB = 1024 PB
Zettabyte (ZB) 1ZB = 1024 EB

1 ZB  = (1024 * 1024 *1024 * 1024 * 1024 * 1024* 1024) Bytes

Atom Payment Gateway Integration in php

Atom Payment Gateway Integration we First introduce Atom –

Atom Technologies is provide end to end transaction service provider, headquarter in Mumbai,India. Atom payment gateway service started in 2006.

Atom Payment integration we create a different php Pages –

  1. Config.php – this file content payment_config class and payment_config  class content payment configuration  information.
  2. Payment.php – this file content payment class and payment class content payment data send and port information
  3. conn.php – this file content database connection information and file is optional. if information store in own database.
  4. response.php – this file is payment response file. this file is  inform  payment successfully or not.
  5. submit.php – this file is posted information in payment gateway.
  6. index.php – this file content HTML information. and using index page posted data.

and create a log folder. log folder content text file and this file create automatically  and this file content posted data information.

Atom Demo payment Gateway PHP Code –

  1. config.php –                                                                                                                                          <?php
    class payment_config{
    var $Url = “https://paynetzuat.atomtech.in/paynetz/epi/fts&#8221;;
    var $Login=”160″;
    var $Password=”Test@123″;
    var $MerchantName=”ATOM”;
    var $TxnCurr=”INR”;
    var $TxnScAmt=”0″;
    }
    ?>

 

2. Payment.php –

<?php

class payment {

var $url = null;

function sendInfo($data){
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_PORT , 443);
//curl_setopt($ch, CURLOPT_SSLVERSION,3);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$returnData = curl_exec($ch);

curl_close($ch);
return $returnData;
}
}
?>

3.submit.php –

<?php
include “config.php”;
include “payment.php”;

class ProcessPayment {

function __construct(){
$this->paymentConfig = new payment_config();
}

function requestMerchant(){
$payment = new payment();
$datenow = date(“d/m/Y h:m:s”);
$modifiedDate = str_replace(” “, “%20”, $datenow);
$payment->url = $this->paymentConfig->Url;
$postFields  = “”;
$postFields .= “&login=”.$this->paymentConfig->Login;
$postFields .= “&pass=”.$this->paymentConfig->Password;
$postFields .= “&ttype=”.$_POST[‘TType’];
$postFields .= “&prodid=”.$_POST[‘product’];
$postFields .= “&amt=”.$_POST[‘amount’];
$postFields .= “&txncurr=”.$this->paymentConfig->TxnCurr;
$postFields .= “&txnscamt=”.$this->paymentConfig->TxnScAmt;
$postFields .= “&clientcode=”.urlencode(base64_encode($_POST[‘clientcode’]));
$postFields .= “&txnid=”.rand(0,999999);
$postFields .= “&date=”.$modifiedDate;
$postFields .= “&custacc=”.$_POST[‘AccountNo’];
$postFields .= “&ru=”.$_POST[‘ru’];
// Not required for merchant
//$postFields .= “&bankid=”.$_POST[‘bankid’];

$sendUrl = $payment->url.”?”.substr($postFields,1).”\n”;

$this->writeLog($sendUrl);

$returnData = $payment->sendInfo($postFields);
$this->writeLog($returnData.”\n”);
$xmlObjArray     = $this->xmltoarray($returnData);

$url = $xmlObjArray[‘url’];
$postFields  = “”;
$postFields .= “&ttype=”.$_POST[‘TType’];
$postFields .= “&tempTxnId=”.$xmlObjArray[‘tempTxnId’];
$postFields .= “&token=”.$xmlObjArray[‘token’];
$postFields .= “&txnStage=1″;
$url = $payment->url.”?”.$postFields;
$this->writeLog($url.”\n”);
header(“Location: “.$url);

}

function writeLog($data){
$fileName = date(“Y-m-d”).”.txt”;
$fp = fopen(“log/”.$fileName, ‘a+’);
$data = date(“Y-m-d H:i:s”).” – “.$data;
fwrite($fp,$data);
fclose($fp);
}

function xmltoarray($data){
$parser = xml_parser_create(”);
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, “UTF-8”);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, trim($data), $xml_values);
xml_parser_free($parser);

$returnArray = array();
$returnArray[‘url’] = $xml_values[3][‘value’];
$returnArray[‘tempTxnId’] = $xml_values[5][‘value’];
$returnArray[‘token’] = $xml_values[6][‘value’];

return $returnArray;
}
}

$processPayment = new ProcessPayment();
$processPayment->requestMerchant();
?>

4. index.php –  this is a demo html page.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
<HEAD>
<TITLE> Payment </TITLE>
</HEAD>

<BODY>
<form action=”submit.php” method=”post”>
/// hidden field are compulsory
<INPUT TYPE=”hidden” NAME=”product” value=”NSE”>
<INPUT TYPE=”hidden” NAME=”TType” value=”NBFundTransfer”>

<INPUT TYPE=”hidden” NAME=”clientcode” value=”007″>
<INPUT TYPE=”hidden” NAME=”AccountNo” value=”1234567890″>
// this is a response page url – ru
<INPUT TYPE=”hidden” NAME=”ru” value=”http://203.114.240.183/paynetzclient/ResponseParam.jsp”&gt;
<input type=”hidden” name=”bookingid” value=”100001″/>

<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td>* Name</td>
<td>:</td>
<td><input name=”udf1″ type=”text” value=”” /></td>
<td><span style=”color:Red;visibility:hidden;”>Client Name is mandatory.</span></td>

</tr>
<tr>
<td>* Email ID</td>
<td>:</td>
<td><input name=”udf2″ type=”text” value=”” /></td>
<td><span style=”color:Red;visibility:hidden;”>Email is mandatory.</span></td>
</tr>
<tr>

<td>* Mobile No</td>
<td>:</td>
<td><input name=”udf3″ type=”text” value=”” /></td>
<td><span style=”color:Red;visibility:hidden;”>Mobile No</span></td>
</tr>
<tr>
<td>* Billing Address</td>
<td>:</td>

<td><input name=”udf4″ type=”text” value=””  /></td>
<td><span style=”color:Red;visibility:hidden;”>Billing Address is mandatory.</span></td>
</tr>
<!–  <tr>
<td>* Bank Name</td>
<td>:</td>
<td><input name=”udf5″ type=”text” value=”bank1″ /></td>
<td><span style=”color:Red;visibility:hidden;”>Bank Name is mandatory.</span></td>

</tr> –>

<tr>
<td>
Amount
</td>
<td>:</td>
<td>
<input type=”text” name=”amount” value=”” />
</td>
</tr>

<tr>
<td>
</td>
<td></td>
<td>
<input type=”submit” name=”Submit” value=”Submit” />
</td>
</tr>
</table>
</form>
</BODY>
</HTML>

5. response.php –

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
<HEAD>
<TITLE> Payment </TITLE>
</HEAD>

<BODY>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td>
<?php if($_POST[‘f_code’]==”Ok”){ ?>
Success : Your Transaction is been processed.
<?php } else { ?>
Failure : Your Transaction couldnot be processed.
<?php } ?>
</td>
</tr>
</table>
</BODY>
</HTML>

6. create a log folder.

 

Delete Record In php With alert message

Head part alert message –

<head>

function ConfirmDelete()
{
var x = confirm(“Are you sure you want to delete?”);
if (x)
return true;
else
return false;
}

</head>

Body Part Php + Html code –

<form name=”myform” action=”delete.php” method=”post”>
<table border=”0″ width=”80%”cellspacing=”2″ cellpadding=”2″ align=”center”>
<tr>
<td colspan=”3″ align=”right” style=”font-size:24px” height=”50px;”> <b>Delete Customer Bill Details</b>
</td>
</tr>
<tr>
<td>&nbsp;
</td>
</tr>
<?php
if(isset($_GET[‘id’]))
{
$id =$_GET[‘id’];
$query = “select * from billdetails where billno = ‘”.$id.”‘”;
$qu1 = mysql_query($query, $con);
while($res= mysql_fetch_array($qu1))
{
$billno = $res[“billno”];
$bdate = $res[“bdate”];
$pname = $res[“pname”];
$venue = $res[“venue”];
$mobile = $res[“mobile”];
$email = $res[“email”];
$servicedes = $res[“servicedes”];
$samount = $res[“samount”];
$ramount = $res[“ramount”];
$famount = $res[“famount”];
$otherser = $res[“otherser”];
$oamount = $res[“oamount”];
$rswords = $res[“rswords”];
$tamount = $res[“tamount”];
$servicetax = $res[“servicetax”];
$discount = $res[“discount”];
$gamount = $res[“gamount”];
}
}
?>
<tr>
<td align=”left” style=”font-size:16px”><b>Bill No.:</b><span class=”star”>*</span>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”billno” value=”<?php echo $billno; ?>” required />
</td>
<td align=”left” style=”font-size:16px”><b>Bill Date:</b><span class=”star”>*</span>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” id=”datepicker3″ name=”billdate” value=”<?php echo $bdate; ?>” required  />
</td>
</tr>
<tr>
<td align=”left” style=”font-size:16px”><b>Party Name:</b><span class=”star”>*</span>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”pname” value=”<?php echo $pname; ?>” required  />
</td>
<td align=”left” style=”font-size:16px”><b>Venue:</b>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”venue” value=”<?php echo  $venue; ?>”  />
</td>
</tr>
<tr>
<td align=”left” style=”font-size:16px”><b>Mobile No.:</b><span class=”star”>*</span>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”mobileno” value=”<?php echo $mobile; ?>” required />
</td>
<td align=”left” style=”font-size:16px”><b>Email Id:</b>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”email” value=”<?php echo $email; ?>”  />
</td>
</tr>
<tr>
<td align=”left” style=”font-size:16px”><b>Service Descriptions:</b>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”sd” value=”<?php echo $servicedes; ?>”   style=”width:234px; height:61px;”/>
</td>
<td align=”left” style=”font-size:16px”><b>Amount:</b><span class=”star”>*</span>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”samount” value=”<?php echo $samount; ?>” required />
</td>
</tr>
<tr>
<td align=”left” style=”font-size:16px”><b>Room Rent Amount: </b>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”ramount” value=”<?php echo $ramount; ?>”  />
</td>
<td align=”left” style=”font-size:16px”><b>Food Beverage Amount:</b>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”famount” value=”<?php echo $famount; ?>”  />
</td>
</tr>

<tr>
<td align=”left” style=”font-size:16px”><b>Other Services:</b>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”os” value=”<?php echo $otherser; ?>”  />
</td>
<td align=”left” style=”font-size:16px”><b>Amount:</b>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”oamount” value=”<?php echo $oamount; ?>”  />
</td>
</tr>
<tr>
<td align=”left” style=”font-size:16px” rowspan=”4″><b> Rs. In words:<b>
</td>
<td align=”left” style=”font-size:16px” rowspan=”4″><input type=”text” name=”words” value=”<?php echo $rswords; ?>”   style=”width:234px; height:75px;” />    </td>
<td align=”left” style=”font-size:16px”><b>Total Amount:</b>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”tamount”value=”<?php echo $tamount; ?>”  />
</td>
</tr>
<tr>
<td align=”left” style=”font-size:16px”><b>Service Tax:</b>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”stax” value=”<?php echo $servicetax; ?>”  required />
</td>
</tr>
<tr>
<td align=”left” style=”font-size:16px”><b>Discount:</b>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”discount” value=”<?php echo $discount; ?>” />
</td>
</tr>
<tr>
<td align=”left” style=”font-size:16px”><b>Grand Total:</b>
</td>
<td align=”left” style=”font-size:16px”><input type=”text” name=”gt” value=”<?php echo $gamount; ?>”  />
</td>

</tr>
<?php
if(isset($_POST[‘Delete’]))
{
if(x == true)
{
$cid = $_POST[‘billno’];
$Query = “delete from billdetails where billno ='”.$cid.”‘”;
$up = mysql_query($Query,$con);
if($up)
{?>

<?php
}
}
else
{ ?>

<?php }
}
?>
<tr>
<td align=”left” style=”font-size:16px” >
</td>
<td align=”left” style=”font-size:16px” colspan=”3″ height=”45px;”> <input type=”submit” name=”Delete” Onclick=”return ConfirmDelete();” value=”Delete”  /></td>
</tr>

</table>
</form>

PayPal standard payment gateway integration in PHP

 

PayPal has two environments such as Sandbox and Real Time. Sandbox environment help developers to do their test transaction before the project go live. Real Time environment is used after project live.

Creating a new Sandbox test account:

At first we need to create a new Sandbox test account. Following steps would be help to create Sandbox account.

  • Step 1 – Go to the https://developer.paypal.com/. Log in with your PayPal account. If you don’t have any PayPal account, first sign up at PayPal. Once the sign up is completed, login with this account.
  • Step 2 – After logged in you would be redirected to the developer home page. Now click on the “Dashboard” link from the top navigation menu.
  • Step 3 – Click on the “Accounts” link under the “Sandbox” label from the left menu section.
  • Step 4 – Create buyer account and merchant account from the “Create Account” link. For buyer account you need to select “Personal” radio button under the “Account type” section or select Business radio button for merchant account.

Database Tables Creation:

We have created two tables named products and payments. products data is stored into the products table and payments table is used for storing the transaction information provided by PayPal.

CREATE TABLE `products` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `image` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `price` float(10,2) NOT NULL,
 `status` tinyint(1) NOT NULL DEFAULT '1',
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `payments` (
 `payment_id` int(11) NOT NULL AUTO_INCREMENT,
 `item_number` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `txn_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `payment_gross` float(10,2) NOT NULL,
 `currency_code` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
 `payment_status` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 PRIMARY KEY (`payment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

We have used four files for complete the PayPal payment process.

db_config.php File:

Database configuration and connection is done here.

<?php
//Database credentials
$dbHost = 'localhost';
$dbUsername = 'root';
$dbPassword = '';
$dbName = 'codexworld';
//Connect with the database
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);

if ($db->connect_errno) {
    printf("Connect failed: %s\n", $db->connect_error);
    exit();
}
?>

products.php File:

In this file all products would be displayed from the MySQL database with PayPal Buy Now button. Follow the comment(<!–– ––>) tags to know about the form hidden fields.

<?php

include 'db_config.php';

//Set useful variables for paypal form
$paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; //Test PayPal API URL
$paypal_id = 'info@codexworld.com'; //Business Email

//fetch products from the database
$results = $db->query("SELECT * FROM products");

while($row = $results->fetch_assoc())
{
?>

    	<img src="images/<?php echo $row['image']; ?>"/>
    	Name: <?php echo $row['name']; ?>
    	Price: <?php echo $row['price']; ?>
    	<form action="<?php echo $paypal_url; ?>" method="post">

        <!-- Identify your business so that you can collect the payments. -->
        <input type="hidden" name="business" value="<?php echo $paypal_id; ?>">
        
        <!-- Specify a Buy Now button. -->
        <input type="hidden" name="cmd" value="_xclick">
        
        <!-- Specify details about the item that buyers will purchase. -->
        <input type="hidden" name="item_name" value="<?php echo $row['name']; ?>">
        <input type="hidden" name="item_number" value="<?php echo $row['id']; ?>">
        <input type="hidden" name="amount" value="<?php echo $row['price']; ?>">
        <input type="hidden" name="currency_code" value="USD">
        
        <!-- Specify URLs -->
        <input type='hidden' name='cancel_return' value='http://example.com/cancel.php'>
        <input type='hidden' name='return' value='http://example.com/success.php'>
        
        <!-- Display the payment button. -->
        <input type="image" name="submit" border="0"
        src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
        <img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
    
    </form>

<?php } ?>

success.php File:

Once the PayPal payment is successful, buyer would be redirected to this page. We have received the transaction information with $_GET variable and insert transaction data into the database. If the payment is successful, then buyer would be see the success message otherwise failed message.

<?php
include 'db_config.php';

//Store transaction information from PayPal
$item_number = $_GET['item_number']; 
$txn_id = $_GET['tx'];
$payment_gross = $_GET['amt'];
$currency_code = $_GET['cc'];
$payment_status = $_GET['st'];

//Get product price
$productResult = $db->query("SELECT price FROM products WHERE id = ".$item_number);
$productRow = $productResult->fetch_assoc();
$productPrice = $productRow['price'];

if(!empty($txn_id) && $payment_gross == $productPrice){
    //Insert tansaction data into the database
    $insert = $db->query("INSERT INTO payments(item_number,txn_id,payment_gross,currency_code,payment_status) VALUES('".$item_number."','".$txn_id."','".$payment_gross."','".$currency_code."','".$payment_status."')");
    $last_insert_id = $db->insert_id;
?>

<h1>Your payment has been successful.</h1>
<h1>Your Payment ID - <?php echo $last_insert_id; ?>.</h1>

<?php
}else{
?>

<h1>Your payment has failed.</h1>

<?php
}
?>

cancel.php File:

If the buyers wish to cancel payment at the PayPal payment page, then buyer would be redirected to this page.

<h1>Your PayPal transaction has been canceled.</h1>

When your application payment flow testing is completed, you need to change $paypal_url variable value with https://www.paypal.com/cgi-bin/webscr and change $paypal_id variable value with the original PayPal Business ID.

Create contact form and send mail in PHP

simple Contact us form create by HTML

<form action="test.php"method="post">
<table width="400"border="0"cellspacing="2"cellpadding="0">
<tr>
<td width="29%"class="bodytext">Your name:</td>
<td width="71%"><input name="name"type="text"id="name"size="32"></td>
</tr>
<tr>
<td class="bodytext">Email address:</td>
<td><input name="email"type="text"id="email"size="32"></td>
</tr>
<tr>
<td class="bodytext">Comment:</td>
<td><textarea name="comment"cols="45"rows="6"id="comment"class="bodytext"></textarea></td>
</tr>
<tr>
<td class="bodytext"> </td>
<td align="left"valign="top"><input type="submit"name="Submit"value="Send"></td>
</tr>
</table>
</form>
Send mail by php code –
<?php
$ToEmail = 'youremail@site.com';
$EmailSubject = 'Site contact form';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html";
$MESSAGE_BODY = "Name: ".$_POST["name"]."";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."";
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>

How to make a calendar by PHP Code

<?php
$monthNames = Array(“January”, “February”, “March”, “April”, “May”, “June”, “July”,
“August”, “September”, “October”, “November”, “December”);
?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
</head>

<body>
<?php
if (!isset($_REQUEST[“month”])) $_REQUEST[“month”] = date(“n”);
if (!isset($_REQUEST[“year”])) $_REQUEST[“year”] = date(“Y”);
?>
<?php
$cMonth = $_REQUEST[“month”];
$cYear = $_REQUEST[“year”];

$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;

if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $cYear – 1;
}
if ($next_month == 13 ) {
$next_month = 1;
$next_year = $cYear + 1;
}
?>
<table width=”200″>
<tr align=”center”>
<td bgcolor=”#999999″ style=”color:#FFFFFF”>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td width=”50%” align=”left”>  <a href=”<?php echo $_SERVER[“PHP_SELF”] . “?month=”. $prev_month . “&year=” . $prev_year; ?>” style=”color:#FFFFFF”>Previous</a></td>
<td width=”50%” align=”right”><a href=”<?php echo $_SERVER[“PHP_SELF”] . “?month=”. $next_month . “&year=” . $next_year; ?>” style=”color:#FFFFFF”>Next</a>  </td>
</tr>
</table>
</td>
</tr>
<tr>
<td align=”center”>
<table width=”100%” border=”0″ cellpadding=”2″ cellspacing=”2″>
<tr align=”center”>
<td colspan=”7″ bgcolor=”#999999″ style=”color:#FFFFFF”><strong><?php echo $monthNames[$cMonth-1].’ ‘.$cYear; ?></strong></td>
</tr>
<tr>
<td align=”center” bgcolor=”#999999″ style=”color:#FFFFFF”><strong>S</strong></td>
<td align=”center” bgcolor=”#999999″ style=”color:#FFFFFF”><strong>M</strong></td>
<td align=”center” bgcolor=”#999999″ style=”color:#FFFFFF”><strong>T</strong></td>
<td align=”center” bgcolor=”#999999″ style=”color:#FFFFFF”><strong>W</strong></td>
<td align=”center” bgcolor=”#999999″ style=”color:#FFFFFF”><strong>T</strong></td>
<td align=”center” bgcolor=”#999999″ style=”color:#FFFFFF”><strong>F</strong></td>
<td align=”center” bgcolor=”#999999″ style=”color:#FFFFFF”><strong>S</strong></td>
</tr>
<?php
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date(“t”,$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth[‘wday’];
for ($i=0; $i<($maxday+$startday); $i++) {
if(($i % 7) == 0 ) echo “<tr>n”;
if($i < $startday) echo “<td></td>n”;
else echo “<td align=’center’ valign=’middle’ height=’20px’>”. ($i – $startday + 1) . “</td>n”;
if(($i % 7) == 6 ) echo “</tr>n”;
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>

Demo Output –

API Integration Using Php code

PHP has a powerful JSON(Api Format) parsing mechanism, which, because PHP is a dynamic language, enables PHP developers to program against a JSON object graph in a very straightforward way. Example 9 shows a PHP page that sends a request to the JSON interface using the file_get_contents API to call the JSON endpoint, and the json_decode function to turn the results into an object graph that can be walked and turned into HTML.

Example 9: Using the API with PHP

<html>
<head>
   <link href="styles.css" rel="stylesheet" type="text/css" />
 <title>PHP Bing</title>
</head>
<body><form method="post" action="<?php echo $PHP_SELF;?>"> 
 Type in a search:<input type="text" id="searchText" name="searchText" value="<?php 
 if (isset($_POST['searchText'])){
  echo($_POST['searchText']); }
  else { echo('ashish');}
  ?>"/>
        <input type="submit" value="Search!" name="submit" id="searchButton" />
<?php
if (isset($_POST['submit'])) {
$request = 'http://api.search.live.net/json.aspx?Appid=<YourAppIDHere>&sources=image&query=' . urlencode( $_POST["searchText"]);
$response  = file_get_contents($request);
$jsonobj  = json_decode($response);
echo('<ul ID="resultList">');                    
                
foreach($jsonobj->SearchResponse->Image->Results as $value)
{
echo('<li class="resultlistitem"><a href="' . $value->Url . '">');
echo('<img src="' . $value->Thumbnail->Url. '"></li>');

}
echo("</ul>");
} ?>
</form>
</body>
</html>

Show and Hide div through javascript.

The only change from above is the JavaScript area. You will notice that the extra space is no longer reserved in the div as it is with the show(), hide() method.

JavaScript:

  $('#d3show').click(function() {
      $('#d1').css('display', 'none');
      $('#d2').css('display', 'none');
      $('#d3').css('display', 'inline');
    });

    $('#d2show').click(function() {
      $('#d1').css('display', 'none');
      $('#d2').css('display', 'inline');
      $('#d3').css('display', 'none');
    });

    $('#d1show').click(function() {
      $('#d1').css('display', 'inline');
      $('#d2').css('display', 'none');
      $('#d3').css('display', 'none');
    });

Update Record in php

 Update simple Record

if(isset($_POST[“update”]))
{
$rid = $_POST[‘id’];
$finame = $_POST[“fname”];
$query1 = “UPDATE users SET FirstName= ‘”.$_POST[fname].”‘, LastName= ‘”.$_POST[lname].”‘, Mobn= ‘”.$_POST[mobile].”‘, Email='”.$_POST[email].”‘ WHERE  Id='”.$rid.”‘”;   // Update Query
$up = mysql_query($query1,$con);
if($up)
{

die(“location.href = ‘SearchandUpdate.php'”);  //if header Function not then use die function.  this use redirect another page.

//header function – header(‘Location:SearchandUpdate.php’); same use die function.

}
else
{
echo “Error : Data not Updated !!!”;    //Error  message.
}
}