Tuesday, March 25, 2014

create a calandar using PHP

create a calandar using PHP


In this tutorial you will learn how to build your own web based calendar using PHP. This calendar is made you can use a plain text editing software such as Notepad.


calandar.php



<?php

$monthNames = Array("January", "February", "March", "April", "May", "June", "July", 

"August", "September", "October", "November", "December");

?>


First we need to check if we have set up our parameters already. If we have not, we set them to the current month and year. (For detailed explanation of date() function please refer to PHP Manual ).

<?php

if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");

if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");

?>


Lets also set the variables that we are going to use in our calandar:

<?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>


// because we don't want our dates to start from 0.

 

<?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";

}

?>


// Now we add just the finishing touches of the html and we have finished the calendar.

</table>

</td>

</tr>

</table>

Monday, March 24, 2014

PHP Interview Questions.


 PHP Interview Questions.

 As PHP language is in trend nowadays that’s why all web developing companies give priority to those candidates who are good in PHP language. These companies hire the desired candidates who have a good knowledge of HTML language as well as PHP language & ask them the following PHP Interview Questions.

Frequently Asked PHP Interview Questions

What is PHP?
PHP is an open source scripting language which is widely used nowadays. The full form of PHP is Hypertext Pre-processor.

What is a PHP File?
Those files which contain text, HTML, JavaScript code, and PHP code are known as PHP files. The default file extension of PHP files is “.php”.

What is the current version of PHP, Apache, MySQL?
The current version of PHP is php 5.1.2, the current version of Apache is Apache 2.1 and the current version of MySQL is MySQL 5.1.

What are the uses of PHP language?
The main uses of PHP language are following:-
1. PHP language is used to generate dynamic page content.
2. Through PHP language user can create, open, read, write, and close files on the server.
3. User can collect form data through PHP language.
4. You can send and receive cookies with the help of PHP language.
5. User can add, delete and modify data in your database through PHP language.

Why we use PHP over other languages?
We use PHP language over other languages beacuse PHP language runs on different platforms like Windows, Linux, Unix, Mac OS X, etc. It is also compatible on all servers like Apache, IIS, etc.

In PHP language, what does a special set of tags <?= and ?> do?
The use of special set of tags in PHP language is to display the output of the program directly to the browser.

What is the common difference b/w include and require in PHP language?
In PHP language the functions include and require are used to handle the failures in a program. The common diffrence between include and require in PHP language is that in case of include function, if the file of any program is not found by include() then it shows a warning to the user but side by side the execution of the script will continue. In case of require function in PHP language, if the file of any program is not found by the rquire() then it shows a fatal error to the user and also it halt the execution of the script.

Saturday, March 8, 2014

pdf using php and fpdf

how can we generate a pdf using php and fpdf

What is FPDF?

FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.
FPDF has other advantages: high level functions. Here is a list of its main features:

1. download fpdf packeage .
2. pdfExample.php 


<?php
require('fpdf.php');

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>


Header, footer, page break and image

<?php
require('fpdf.php');

class PDF extends FPDF
{
// Page header
function Header()
{
    // Logo
    $this->Image('logo.png',10,6,30);
    // Arial bold 15
    $this->SetFont('Arial','B',15);
    // Move to the right
    $this->Cell(80);
    // Title
    $this->Cell(30,10,'Title',1,0,'C');
    // Line break
    $this->Ln(20);
}

// Page footer
function Footer()
{
    // Position at 1.5 cm from bottom
    $this->SetY(-15);
    // Arial italic 8
    $this->SetFont('Arial','I',8);
    // Page number
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}

// Instanciation of inherited class
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
for($i=1;$i<=40;$i++)
    $pdf->Cell(0,10,'Printing line number '.$i,0,1);
$pdf->Output();
?>

 

Cell

Cell(float w [, float h [, string txt [, mixed border [, int ln [, string align [, boolean fill [, mixed link]]]]]]])


$pdf->Cell(20,10,'Title',1,1,'C');

SetFont

// Times regular 12
$pdf->SetFont('Times');
// Arial bold 14
$pdf->SetFont('Arial','B',14);
// Removes bold
$pdf->SetFont('');
// Times bold, italic and underlined 14
$pdf->SetFont('Times','BIU');

 

Family font. It can be either a name defined by AddFont() or one of the standard families (case insensitive):
  • Courier (fixed-width)
  • Helvetica or Arial (synonymous; sans serif)
  • Times (serif)
  • Symbol (symbolic)
  • ZapfDingbats (symbolic)
It is also possible to pass an empty string. In that case, the current family is kept.
style
Font style. Possible values are (case insensitive):
  • empty string: regular
  • B: bold
  • I: italic
  • U: underline

 


Thursday, January 30, 2014

Store File In DATABASE

Here I am going to tell you how can we send a file in database.
This is very general problem for a php developer
its is very basic PHP code you have to study and apply it.

1.upload_file.php
2.Add_file.php
3.List_file.php
4.Get_file.php

create database

username:root
password:
datbasename:test2
tablename:file

table entity:

CREATE TABLE `file` (

    `id`    &nbsp;   Int Unsigned Not Null Auto_Increment,

    `name`      VarChar(255) Not Null Default 'Untitled.txt',

    `mime`      VarChar(50) Not Null Default 'text/plain',

    `size`      BigInt Unsigned Not Null&nbsp;Default 0,

    `data`      MediumBlob Not Null,

    `created`   DateTime Not Null,

    PRIMARY KEY (`id`)

)
<!DOCTYPE html>
<head>
    <title>MySQL file upload example</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
    <form action="add_file.php" method="post" enctype="multipart/form-data">
        <input type="file" name="uploaded_file"><br>
        <input type="submit" value="Upload file">
    </form>
    <p>
        <a href="list_files.php">See all files</a>
    </p>
</body>
</html>  


1.upload_file.php
 
<!DOCTYPE html>
<head>
    <title>MySQL file upload example</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
    <form action="add_file.php" method="post" enctype="multipart/form-data">
        <input type="file" name="uploaded_file"><br>
        <input type="submit" value="Upload file">
    </form>
    <p>
        <a href="list_files.php">See all files</a>
    </p>
</body>
</html>



<?php

// Check if a file has been uploaded

if(isset($_FILES['uploaded_file'])) {

    // Make sure the file was sent without errors

    if($_FILES['uploaded_file']['error'] == 0) {

        // Connect to the database

        $dbLink = new mysqli('127.0.0.1', 'user', 'pwd', 'myTable');

        if(mysqli_connect_errno()) {

            die("MySQL connection failed: ". mysqli_connect_error());

        }

        // Gather all required data

        $name = $dbLink->real_escape_string($_FILES['uploaded_file']['name']);

        $mime = $dbLink->real_escape_string($_FILES['uploaded_file']['type']);

        $data = $dbLink->real_escape_string(file_get_contents($_FILES  ['uploaded_file']['tmp_name']));

        $size = intval($_FILES['uploaded_file']['size']);

        // Create the SQL query

        $query = "

            INSERT INTO `file` (

                `name`, `mime`, `size`, `data`, `created`

            )

            VALUES (

                '{$name}', '{$mime}', {$size}, '{$data}', NOW()

            )";

        // Execute the query

        $result = $dbLink->query($query);

        // Check if it was successfull

        if($result) {

            echo 'Success! Your file was successfully added!';

        }

        else {

            echo 'Error! Failed to insert the file'

               . "<pre>{$dbLink->error}</pre>";

        }

    }

    else {

        echo 'An error accured while the file was being uploaded. '

           . 'Error code: '. intval($_FILES['uploaded_file']['error']);

    }

    // Close the mysql connection

    $dbLink->close();

}

else {

    echo 'Error! A file was not sent!';

}

// Echo a link back to the main page

echo '<p>Click <a href="index.html">here</a> to go back</p>';

?>

4.Get_file.php

<?php

// Connect to the database

$dbLink = new mysqli('127.0.0.1', 'user', 'pwd', 'myTable');

if(mysqli_connect_errno()) {

    die("MySQL connection failed: ". mysqli_connect_error());

}

// Query for a list of all existing files

$sql = 'SELECT `id`, `name`, `mime`, `size`, `created` FROM `file`';

$result = $dbLink->query($sql);

// Check if it was successfull

if($result) {

    // Make sure there are some files in there

    if($result->num_rows == 0) {

        echo '<p>There are no files in the database</p>';

    }

    else {

        // Print the top of a table

        echo '<table width="100%">

                <tr>

                    <td><b>Name</b></td>

                    <td><b>Mime</b></td>

                    <td><b>Size (bytes)</b></td>

                    <td><b>Created</b></td>

                    <td><b>&nbsp;</b></td>

                </tr>';

        // Print each file

        while($row = $result->fetch_assoc()) {

            echo "

                <tr>

                    <td>{$row['name']}</td>

                    <td>{$row['mime']}</td>

                    <td>{$row['size']}</td>

                    <td>{$row['created']}</td>

                    <td><a href='get_file.php?id={$row['id']}'>Download</a></td>

                </tr>";

        }

        // Close table

        echo '</table>';

    }

    // Free the result

    $result->free();

}

else

{

    echo 'Error! SQL query failed:';

    echo "<pre>{$dbLink->error}</pre>";

}

// Close the mysql connection

$dbLink->close();

?>

Monday, January 20, 2014

PHP with OOPS

here you have to construct two PHP files 

----------------------------------------------------------------------------------------------

 index.php

<?php
include("connection.php");
$obj=new apoo;
if(isset($_POST['SUB']))
{
   
    $un=$_POST['uname'];
    $up=$_POST['upass'];
   
    $yyy=$obj->AddUss($un,$up);
    }
//header("location:registration.php");
    ?>

<html>
<body>
<form method="post" action="">
username
<input type="text" name="uname" />
password

<input type="text" name="upass" />

<input type="submit" name="SUB" />

</form>
</body>
</html>


--------------------------------------------------------------------------------------------------------

connection.php


<?php

session_start();
class CLASSNAME
{
    var $connect;
    function __construct()
    {
        $this->connect=new MySQLi("localhost","root","","sun12k");
        echo "success";
    }
  
    function AddUss($un,$up)
    {
        $addU=$this->connect->prepare("insert into`nametable`(firstname,lastname)VALUES(?,?);");
        $addU->bind_param("ss",$un,$up);
        $addU->execute();
    echo "success2";
       
        //    header("location:home.php");       
        }
}
?>

Friday, January 10, 2014

top Company

 

 

 TOP Compnies

 

 

 

 

 

Kuliza Technologies Pvt Ltd

Hosur Main Rd, Bommanahalli , Bangalore / Bengaluru- 560068
Phone No. :(080) 42674300
Kuliza is a software development company that has built web, mobile and social experiences for global clients

Summit IT Solutions Pvt Ltd

Plot No.3 & 3A, EOIZ Industrial Area Sy.No.85 and 86, Sadaramangala Village Krishnarajapuram Hobli, Whitefield , Bangalore / Bengaluru- 560066
Phone No. :(080) 33071911
Symphony SUMMIT a cost effective, ITIL V3 certified, single window solution that unifies key applications across service, availability, people, and project and asset management.

1to1help.net Pvt Ltd

2728, Adjacent to ADE Compound 80 Feet Road (CMH Road Junction) Indiranagar , Bangalore / Bengaluru- 560038
Phone No. :(080) 71000121
1to1helps unique Employee Assistance Programme, developed over decade of corporate counseling experience in India, offers a combination of services ideally suited to the Indian setting.

Prudent Insurance Brokers Pvt Ltd

3rd Flr. "Sai Shakti" 2207 HAL Stage III 80 Feet Road Kodihalli , Bangalore / Bengaluru- 560008
Phone No. :(080) 30242000
Passionate client advocates, custodians of our clients assets, brokers with integrity and capability - this is Prudent Insurance Brokers. We help you protect your business and control insurance costs.

ACTT Global

101 Sadashiv Apts 20,Langford Garden Rd , Richmond Circle , Bangalore / Bengaluru- 560025
Phone No. :(080) 22107376
ACTT Global is a performance improvement enterprise.

Greytip Software Pvt Ltd

30/31, 100 Feet Road, II Block Koramangala , Bangalore / Bengaluru- 560034
Phone No. :(080) 40225900
Greytip Software is a leading HR & Payroll software solutions company.
 

Peak Performance Trainings

4, 2nd Floor, 324/62, Sarvasheela Complex, Bellary Main Road, Ganganagar, , Bangalore / Bengaluru- 560032
Phone No. :(080) 41378973
Peak Performance Trainings is a training company Headquartered at Bangalore.
 

Clearnet Solutions India Pvt Ltd

19 1st Floor Umiya Emporium 99 Hosur Main Road - Dairy Circle Side Opposite Forum Mall , Bangalore / Bengaluru- 560029
Phone No. :(080) 9019177688
Clearnet Solutions India Private Limited is a networking company.

10kInfo Data Solutions Pvt Ltd


Industry :Information Technology (IT)
Sub Industry :IT- Consulting
Company Type :SMEs
Level of Office :Head Office
Location :    Bangalore / Bengaluru / Karnataka - 560027


12th Avenue


Industry :Hospitality
Sub Industry :Hotels
Company Type :SMEs
Level of Office :Head Office
Location :    Bangalore / Bengaluru / Karnataka - 560008


24/7 Customer Pvt Ltd


Industry :ITES - BPO , KPO , LPO , MT
Sub Industry :BPO , KPO , Call centre
Company Type :MNC
Level of Office :Head Office
Location :    Bangalore / Bengaluru / Karnataka - 560071



24x7 Learning Pvt Ltd


Industry :Institutes , Training
Sub Industry :Educational Consultants, Institutes - Others
Company Type :Industry Best
Level of Office :Head Office
Location :    Bangalore / Bengaluru / Karnataka - 560042


37th Crescent


Industry :Hospitality
Sub Industry :Hotels, Restaurants, Banquet Halls, Associations
Company Type :Industry Best
Level of Office :Head Office
Location :    Bangalore / Bengaluru / Karnataka - 560001


3AG Network Solutions Pvt Ltd


Industry :Information Technology (IT)
Sub Industry :IT- ERP , CRM
Company Type :SMEs
Level of Office :Head Office
Location :    Bangalore / Bengaluru / Karnataka - 560003


3C Consultants Pvt Ltd


Industry :Consulting
Sub Industry :Placement , HR , Training
Company Type :SMEs
Level of Office :Head Office
Location :    Bangalore / Bengaluru / Karnataka - 560017


3D Concept Analysis & Development India Pvt Ltd


Industry :Information Technology (IT)
Sub Industry :IT Software , QA -Testing
Company Type :SMEs
Level of Office :Head Office
Location :    Bangalore / Bengaluru / Karnataka - 560040


3D Concept Tooling Pvt Ltd


Industry :Engineering
Sub Industry :Machineries , Instruments
Company Type :SMEs
Level of Office :Head Office
Location :    Bangalore / Bengaluru / Karnataka - 560058


3D Solid Compression Pvt Ltd


Industry :Information Technology (IT)
Sub Industry :IT Software , QA -Testing
Company Type :SMEs
Level of Office :Head Office
Location :    Bangalore / Bengaluru / Karnataka - 560003








How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide

How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide If you're looking to host a Laravel project on Hostinger’s hPa...