Wednesday, April 18, 2012

PHP counter for visiter

0 comments

PHP counter for visiter….

First we create a table in mysql database.

Table name counter. And its contain 2 column for showing the no. of visitor on php page.

Table coading in mysql…

CREATE TABLE `counter` (

`id` INT( 10 ) NOT NULL ,
`cntr` INT( 100 ) NOT NULL

) ENGINE = MYISAM ;

Now insert the first value…

INSERT INTO `counter` ( `id` , `cntr` )
VALUES (

'1', '1'

);

Here we take a field id and counter.

Coading at visiter page….

< ?php

include("connect/conn.php");

mysql_query("update counter set cntr = cntr +1 where id ='1';");

?>

This will update the value of counter by one after refresh the page.

Show the no of visitor on page….

< ?php

$q = mysql_query("select * from counter where id ='1' ");

$row = mysql_fetch_array($q);

echo $row['cntr'];

?>

This code show the total no. of visitor on page.

Join Query in PHP

0 comments


Join query is mysql...

Inner join :- In this join query there is a query for fatching the data

from more then one table according to the condition.
if we want to get the data from table1 and table2 where id of both table are equal.

$query=select * from table1 innerjoin table2 on table1.id=table2.id.

mysql _query($query);

this will gave you the result where id of table1 and table2 are equal.


Leftjoin :- In this join query there is a query for fatching the data from more then one table

according to the condition where all data of left table are show.
if we want to get the data from table1 and table2 where id of both table are equal and all data of left table1.

$query=select * from table1 leftjoin on table1.id=table2.id.

mysql _query($query);

this will gave you the result where id of table1 and table2 are equal and all data of left data are show .


Rightjoin :- In this join query there is a query for fatching the data from more then one table

according to the condition where all data of left table are show.
if we want to get the data from table1 and table2 where id of both table are equal and all data of right table1.

$query=select * from table1 Rightjoinon table1.id=table2.id.

mysql _query($query);

this will gave you the result where id of table1 and table2 are equal and

all data of right are show .

Tuesday, April 17, 2012

Current Time in PHP

1 comments
Time of System
This will help you to get the time according to you.
if we want to get the time from time(); function then it will give us the GMT time.
but we need our local time.....
Time of India....

< ?php
$h=date("h");
$m=date("i");
$s=date("s");
$h=$h+5;
$m=$m+30;
if($h>24)
{
$h=$h-24;
}
if($m>60)
{
$h=$h+1;
$m=$m-60;
}

echo $h.":".$m.":".$s;
?>

Here $h is hour,$m is minut and $s is second....

Show Image to the browser

0 comments

This is the code for image upload in filesystem through PHP.

This will gave you the source of file ,Name of file ,type of file and the size of image file.

< ?php

if(move_uploaded_file($_FILES["file"]["tmp_name"],

"image/" . $_FILES["file"]["name"]))

{

$t= "image/" . $_FILES["file"]["name"];

? >

code for image show......

move_uploaded_file this is the php code for image upload to a folder....

$_FILES["file"]["name"] this is the name of php uploaded file.....

$_FILES["file"]["size"] this is the size php uploaded file..

$_FILES["file"]["type"] this is the size php uploaded file..

here file is the name of the browse field.


PHP FILE INCLUDE……

0 comments
We use to include the file in our page by using INCLUDE function.
Include function is use by 4 method ……..
1 include(‘/filepath/filename’);
2 require(‘/filepath/filename’);
3 include_once(‘/filepath/filename’);
4 require_once(‘/filepath/filename’);

include and require include file when this function is called.
include_once and require_once include only once in a file.
include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless.
include('connect/connection.php');

Connection file for Database….
< ?php mysql_connect("localhost","root","pass") ; mysql_select_db("myproject") ; ?>
mysql_connect is a php function that is use to connect to the server….
Here LOCALHOST is the server.
ROOT is user name for this server.
Pass is tha password for this server for the ROOT user.

HOME PAGE

Sunday, April 15, 2012

About PHP

3 comments
PHP stands for PHP: Hypertext Preprocessor.

PHP is a influential tool for making dynamic and cooperative Web pages.

this is server side scripting language....

this is open source and free to use...

php is plateform independent.....

extension of php file is...
.php
.php3
.phtml

PHP is easily embedded with HTML.
PHP pages are ordinary HTML pages that
escape into PHP mode only when necessary.

Code for PHP calling in HTML:-

< ?php //php code start here
$name=Nilesh;
$last_name=Gupta
?>
Hello Friends How are you!!!!!!

< ?php echo $name; echo $last_name; ?>
You are visiting our site at < ?php echo date("F j, Y");?>

Here echo is use for show output to the browser.....
date() is a php function...
F:gave us the month of the year.
j:date in numeric .
Y gave us the year in 4 dgit......

HOME PAGE