Sunday, 2 August 2015

Program to find prime numbers in PHP

Program to find prime numbers in PHP

<?php
//Program to find prime numbers in php

$counts =19;

for( $a = 2; $a <= $counts; $a++ )
{
for( $s = 2; $s < $a; $s++ )
{
if( $a % $s == 0 )
{
break;
}

}
if( $s == $a )
echo “Prime Number : “, $a, “<br>”;
}
?>

HERE IS THE OUTPUT

Prime Number : 2
Prime Number : 3
Prime Number : 5
Prime Number : 7
Prime Number : 11
Prime Number : 13
Prime Number : 17
Prime Number : 19

Monday, 13 April 2015

Difference Between Primary Key and Unique Key In Sql Server

Difference Between Primary Key and Unique Key In Sql Server


Both PRIMARY KEY and UNIQUE KEY enforces the Uniqueness of the values (exp: avoids duplicate values) on the columns on which it is defined.  Also these key’s can Uniquely identify each row in database table.

Here are some major difference between PRIMARY KEY and UNIQUE KEY:



PRIMARY KEY UNIQUE KEY
NULL It doesn’t allow Null values.
Because of this we refer
PRIMARY KEY = UNIQUE KEY + Not Null CONSTRAINT
Allows Null value. But only one Null value.
INDEX By default it adds a clustered index By default it adds a UNIQUE non-clustered index
LIMIT A table can have only one PRIMARY KEY Column[s] A table can have more than one UNIQUE Key Column[s]
CREATE SYNTAX Below is the sample example for defining a single column as a PRIMARY KEY column while creating a table:
CREATE TABLE dbo.Customer
(
Id INT NOT NULL PRIMARY KEY,
FirstName VARCHAR(100),
LastName VARCHAR(100),
City VARCHAR(50)
)
Below is the Sample example for defining multiple columns as PRIMARY KEY. It also shows how we can give name for the PRIMARY KEY:
CREATE TABLE dbo.Customer
(
Id INT NOT NULL,
FirstName VARCHAR(100) NOT NULL,
LastName VARCHAR(100),
City VARCHAR(50),
CONSTRAINT PK_CUSTOMER PRIMARY KEY (Id,FirstName)
)
Below is the sample example for defining a single column as a UNIQUE KEY column while creating a table:
CREATE TABLE dbo.Customer
(
Id INT NOT NULL UNIQUE,
FirstName VARCHAR(100),
LastName VARCHAR(100),
City VARCHAR(50)
)
Below is the Sample example for defining multiple columns as UNIQUE KEY. It also shows how we can give name for the UNIQUE KEY:
CREATE TABLE dbo.Customer
(
Id INT NOT NULL,
FirstName VARCHAR(100) NOT NULL,
LastName VARCHAR(100),
City VARCHAR(50),
CONSTRAINT UK_CUSTOMER UNIQUE (Id,FirstName)
)
ALTER SYNTAX Below is the Syntax for adding PRIMARY KEY CONSTRAINT on a column when the table is already created and doesn’t have any primary key:
ALTER TABLE dbo.Customer
ADD CONSTRAINT PK_CUSTOMER PRIMARY KEY (Id)
Below is the Syntax for adding UNIQUE KEY CONSTRAINT on a column when the table is already created:
ALTER TABLE dbo.Customer
ADD CONSTRAINT UK_CUSTOMER UNIQUE (Id)
DROP SYNTAX Below is the Syntax for dropping a PRIMARY KEY:
ALTER TABLE dbo.Customer
DROP CONSTRAINT PK_CUSTOMER
Below is the Syntax for dropping a UNIQUE KEY:
ALTER TABLE dbo.Customer
DROP CONSTRAINT UK_CUSTOMER

Difference Between Primary Key and Unique Key In Sql Server

Wednesday, 8 April 2015

Display Loading Image While Page Loads

Display Loading Image While Page Loads

<html>
<body>
<div class="image_loader"></div>
<table>
<tr><td>Name :</td><td>Sharanu</td></tr>
<tr><td>Profile</td><td>Website Developer</td></tr>
</table>
</body>
</html>

<style>
.image_loader {
      width: 100%;
        height: 100%;
        z-index: 5;
        position: absolute;
background: url('images/loading.gif') 50% 50% no-repeat rgb(249,249,249);
}
</style>

//create image folder for storing the image to display as per the in css path and also you can download image from this url http://sierrafire.cr.usgs.gov/images/loading.gif 

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(window).load(function() {
$(".image_loader").fadeOut("slow");
})
</script>

Friday, 20 February 2015

Generate Excel Report in Codeigniter

Generate Excel Report in Codeigniter


1.Controller file its just for examplle

$data['excel_data'] = $this->excel_model->view();  (this value with array and in model you should be create view function)

2. View file


These 3 line for generate excel report those line should be top on the view file
<?php
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="DonationList.xls"');
header('Cache-Control: max-age=0');
?>
<table width="100%" border="1">
    <tr>
        <th>Id</th>
        <th>Donor Name</th>
</tr>
<?php foreach ($excel_data as $row): ?>
    <tr>
        <td><?php echo $row->id; ?></td>
        <td><?php echo $row->name; ?></td>
</tr>
</table>

once you run this type file in Codeigniter you get downloadable excel  sheet

Generate Excel Report in Codeigniter

Monday, 16 February 2015

How To Change Ring & Vibration Settings in Yureka



Here is the solution how to make ring with vibrate in YU Yureka




If you  not found the Sound option in click Plus(+) button on the top there will show the list you just select sound it will show in the list then you can change to ring and vibrate mode it will work 100%

Wednesday, 4 February 2015

How to Install Zend Framework

How to Install Zend Framework

Detail about How to install zend framework 2 in 5 steps


1.Download the zip file using below link

https://github.com/zendframework/ZendSkeletonApplication
after downloading the zip folder extract in and copy the all folders, paste it in your project folder example path : C:\xampp\htdocs\zend

2.Download the composer exe file from this url
https://getcomposer.org/Composer-Setup.exe
and install it while instaling time if it is give the error plz
open the php.ini file form this url example :  C:\xampp\php and Uncomment the line extension=php_openssl.dll by removing the semicolon at the beginning.
Now you are good to install Composer.

3.Open command prompt and open project folder path in command prompt example : c:xampp\htdocs\zend
and paste this code and run it for updating the composer : php composer.phar self-update

4.After this it will download 100% then you paste this code and run it for install the updated composer in same command prompt like : php composer.phar install

5.Finally its installed now you can open your website link in local  like

http://localhost/zend/public/

Example Screen will show





How to install zend framework