Friday, 19 September 2014

Write a C program to calculate pow(x,n)?

There are again different methods to do this in C

Brute force C program
int pow(int x, int y)
{
if(y == 1) return x ;
return x * pow(x, y-1) ;
}

Divide and Conquer C program
#include <stdio.h>
int main(int argc, char*argv[])
{
printf("\n[%d]\n",pow(5,4));
}
int pow(int x, int n)
{
if(n==0)return(1);
else if(n%2==0)
{
return(pow(x,n/2)*pow(x,(n/2)));
}
else
{
return(x*pow(x,n/2)*pow(x,(n/2)));
}
}
Also, the code above can be optimized still by calculating pow(z, (n/2)) only one time (instead of twice) and using its value in the two return() expressions above.

Write a C program to reverse a string

There are a number of ways one can reverse strings. Here are a few of them. These should be enough to impress the interviewer! The methods span from recursive to nonr-ecursive (iterative). Also note that there is a similar question about reversing the words in a sentence, but still keeping the words in place. That is
I am a good boy
would become
boy good a am I

This is dealt with in another question. Here I only concentrate on reversing strings. That is
I am a good boy
would become
yob doog a ma I
Here are some sample C programs to do the same

Method1 (Recursive)
#include <stdio.h>
static char str[]="STRING TO REVERSE";
int main(int argc, char *argv)
{
printf("\nOriginal string : [%s]", str);
// Call the recursion function
reverse(0);
printf("\nReversed string : [%s]", str);
return(0);
}
int reverse(int pos)
{
// Here I am calculating strlen(str) everytime.
// This can be avoided by doing this computation
// earlier and storing it somewhere for later use.
if(pos<(strlen(str)/2))
{
char ch;
// Swap str[pos] and str[strlen(str)-pos-1]
ch = str[pos];
str[pos]=str[strlen(str)-pos-1];
str[strlen(str)-pos-1]=ch;
// Now recurse!
reverse(pos+1);
}
}


Method2
#include <stdio.h>
#include <malloc.h>
#include <string.h>
void ReverseStr ( char *buff, int start, int end )
{
char tmp ;
if ( start >= end )
{
printf ( "\n%s\n", buff );
return;
}
tmp = *(buff + start);
*(buff + start) = *(buff + end);
*(buff + end) = tmp ;
ReverseStr (buff, ++start, --end );
}
int main()
{
char buffer[]="This is Test";
ReverseStr(buffer,0,strlen(buffer)-1);
return 0;
}


Method3
public static String reverse(String s)
{
int N = s.length();
if (N <= 1) return s;
String left = s.substring(0, N/2);
String right = s.substring(N/2, N);
return reverse(right) + reverse(left);
}


Method4

for(int i = 0, j = reversed.Length - 1; i < j; i++, j--)
{
char temp = reversed[i];
reversed[i] = reversed[j];
reversed[j] = temp;
}
return new String(reversed);

Method5
public static String reverse(String s)
{
int N = s.length();
String reverse = "";
for (int i = 0; i < N; i++)
reverse = s.charAt(i) + reverse;
return reverse;
}


Method6
public static String reverse(String s)
{
int N = s.length();
char[] a = new char[N];
for (int i = 0; i < N; i++)
a[i] = s.charAt(N-i-1);
String reverse = new String(a);
return reverse;
}

C program for calculating the factorial of a number

Here is a recursive C program
fact(int n)
{
int fact;
if(n==1)
62
return(1);
else
fact = n * fact(n-1);
return(fact);
}
Please note that there is no error handling added to this function (to check if n is negative or 0. Or if n is too large for the system to handle). This is true for most of the answers in this website. Too much error handling and standard compliance results in a lot of clutter making it difficult to concentrate on the crux of the solution. You must of course add as much error handling and comply to the standards of your compiler when you actually write the code to implement these algorithms.

C program to swap two variables without using a temporary variable

The best way to swap two variables is to use a temporary variable.
int a,b,t;
t = a;
a = b;
b = t;
There is no way better than this as you will find out soon. There are a few slick expressions that do swap variables without using temporary storage. But they come with their own set of problems.

Method1 (The XOR trick)
a ^= b ^= a ^= b;
Although the code above works fine for most of the cases, it tries to modify variable 'a' two times between  sequence points, so the behavior is undefined. What this means is it wont work in all the cases. This will also not work for floating-point values. Also, think of a scenario where you have written your code like this
swap(int *a, int *b)
{
*a ^= *b ^= *a ^= *b;
}
Now, if suppose, by mistake, your code passes the pointer to the same variable to this function. Guess what happens? Since Xor'ing an element with itself sets the variable to zero, this routine will end up setting the variable to zero (ideally it should have swapped the variable with itself). This scenario is quite possible in sorting algorithms which sometimes try to swap a variable with itself (maybe due to some small, but not so fatal coding error). One solution to this problem is to check if the numbers to be swapped are already equal to each other.
swap(int *a, int *b)
{
if(*a!=*b)
{
*a ^= *b ^= *a ^= *b;
}
}

Method2
This method is also quite popular
a=a+b;
b=a-b;
a=a-b;
But, note that here also, if a and b are big and their addition is bigger than the size of an int, even this might  end up giving you wrong results.

Method3

One can also swap two variables using a macro. However, it would be required to pass the type of the  variable to the macro. Also, there is an interesting problem using macros.
Suppose you have a swap macro which looks something like this
#define swap(type,a,b) type temp;temp=a;a=b;b=temp;
Now, think what happens if you pass in something like this
swap(int,temp,a) //You have a variable called "temp" (which is quite po
ssible).
This is how it gets replaced by the macro
int temp;
temp=temp;
temp=b;
b=temp;
Which means it sets the value of "b" to both the variables!. It never swapped them! Scary,
isn't it?
So the moral of the story is, dont try to be smart when writing code to swap variables.
Use a temporary variable. Its not only fool proof, but also easier to understand and
maintain.

Implement the substr() function in C

Here is a C program which implements the substr() function in C.
int main()
{
char str1[] = "India";
char str2[25];
substr(str2, str1, 1, 3);
printf("\nstr2 : [%s]", str2);
return(0);
}
substr(char *dest, char *src, int position, int length)
{
dest[0]='\0';
strncat(dest, (src + position), length);
}

Write your own printf() function in C

This is again one of the most frequently asked interview questions. Here is a C program which implements a basic version of printf(). This is a really, really simplified version of printf(). Note carefully how floating point and other compilcated support has been left out. Also, note how we use low level puts() and putchar(). Dont make a fool of yourself by using printf() within the implementation of printf()!
#include<stdio.h>
#include<stdarg.h>
main()
{
void myprintf(char *,...);
char * convert(unsigned int, int);
int i=65;
char str[]="This is my string";
myprintf("\nMessage = %s%d%x",str,i,i);
}
void myprintf(char * frmt,...)
{
char *p;
int i;
unsigned u;
char *s;
va_list argp;
va_start(argp, fmt);
p=fmt;
for(p=fmt; *p!='\0';p++)
{
if(*p=='%')
{
putchar(*p);continue;
}
p++;
switch(*p)
{
case 'c' : i=va_arg(argp,int);putchar(i);break;
case 'd' : i=va_arg(argp,int);
if(i<0){i=-i;putchar('-
');}puts(convert(i,10));break;
case 'o': i=va_arg(argp,unsigned int); puts(convert(i,8));b
reak;
case 's': s=va_arg(argp,char *); puts(s); break;
case 'u': u=va_arg(argp,argp, unsigned int); puts(convert(u
,10));break;
47
case 'x': u=va_arg(argp,argp, unsigned int); puts(convert(u
,16));break;
case '%': putchar('%');break;
}
}
va_end(argp);
}
char *convert(unsigned int, int)
{
static char buf[33];
char *ptr;
ptr=&buf[sizeof(buff)-1];
*ptr='\0';
do
{
*--ptr="0123456789abcdef"[num%base];
num/=base;
}while(num!=0);
return(ptr);
}

How do you find the middle of a linked list? Write a C program to return the middle of a linked list

Method1
p=head;
q=head;
if(q->next->next!=NULL)
{
p=p->next;
q=q->next->next;
}
printf("The middle element is %d",p->data);
Here p moves one step, where as q moves two steps, when q reaches end, p will be at the
middle of the linked list.

Method2

struct node *middle(struct node *head)
{
struct node *middle=NULL;
int i;
for(i=1; head; head=head->next,i++)
{
if(i==1)
middle=head;
else if ((i%2)==1)
middle=middle->next;
}
return middle;
}
In a similar way, we can find the 1/3 th node of linked list by changing (i%2==1) to
(i%3==1) and in the same way we can find nth node of list by changing (i%2==1) to
(i%n==1) but make sure ur (n<=i).
p=head;
q=head;
if(q->next->next!=NULL)
{
p=p->next;
q=q->next->next;
}
printf("The middle element is %d",p->data);

Here p moves one step, where as q moves two steps, when q reaches end, p will be at the
middle of the linked list.

Method2
struct node *middle(struct node *head)
{
struct node *middle=NULL;
int i;
for(i=1; head; head=head->next,i++)
{
if(i==1)
middle=head;
else if ((i%2)==1)
middle=middle->next;
}
return middle;
}


In a similar way, we can find the 1/3 th node of linked list by changing (i%2==1) to
(i%3==1) and in the same way we can find nth node of list by changing (i%2==1) to
(i%n==1) but make sure ur (n<=i).

How do you sort a linked list? Write a C program to sort a linked list

This is a very popular interview question, which most people go wrong. The ideal solution to this problem is to keep the linked list sorted as you build it. This really saves a lot of time which would have been required to sort it.

Method1 (Usual method)
The general idea is to decide upon a sorting algorithm (say bubble sort). Then, one needs to come up with different scenarios to swap two nodes in the linked list when they are not in the required order. The different scenarios would be something like
1. When the nodes being compared are not adjacent and one of them is the first node.
2. When the nodes being compared are not adjacent and none of them is the first node
3. When the nodes being compared are adjacent and one of them is the first node.
4. When the nodes being compared are adjacent and none of them is the first node.
One example bubble sort for a linked list goes like this

for(i = 1; i < n; i++)
{
p1 = head;
p2 = head->next;
p3 = p2->next;
for(j = 1; j <= (n - i); j++)
{
if(p2->value < p3->value)
{
p2->next = p3->next;
p3->next = p2;
p1->next = p3;
p1 = p3;
p3 = p2->next;
}
else
{
p1 = p2;
p2 = p3;
p3 = p3->next;
}
}
}
As you can see, the code becomes quite messy because of the pointer logic. Thats why I have not elaborated too much on the code, nor on variations such as soring a doubly linked list. You have to do it yourself once to understand it.

Method1 (Divide and Conquer using merge sort)
The pseudocode for this method is
typedef struct node
{
int value;
struct node *next;
}mynode;
mynode *head, *tail;
int size;
mynode *mergesort(mynode *list, int size);
void display(mynode *list);
mynode *mergesort(mynode *list, int size)
{
int size1, size2;
mynode *tempnode1, *tempnode2, *tempnode3;
if(size<=2)
{
if(size==1)
{
// Nothing to sort!
return(list);
}
else
{
if(list->value < list->next->value
{
// These 2 nodes are already in right order, no need to sor
t
return(list);
}
else
{
// Need to swap these 2 nodes
/* Here we have 2 nodes
*
* node 1 -> node2 -> NULL
*
* This should be converted to
*
* node2 -> node1 -> NULL
*
*/
tempnode1 = list;
tempnode2 = list->next;
tempnode2->next = tempnode1;
tempnode1->next = NULL;
return(tempnode2);
}
}
}
else
{
// The size of the linked list is more than 2.
// Need to split this linked list, sort the
// left and right sub-linked lists and merge.
// Split.
// tempnode1 will have the first half of the linked list of size
"size1".
// tempnode2 will have the second half of the linked list of size
"size2".
<CODE TO SPLIT THE LINKED LIST INTO TWO>
// Sort the two halves recursively
tempnode1 = mergesort(tempnode1, size1);
tempnode2 = mergesort(tempnode2, size2);
// Now merge the sorted lists back, let tempnode3 point to that n
ew list.
<CODE TO MERGE THE 2 LINKED LISTS BACK INTO A SINGLE SORTED LINKE
D LIST>
return(tempnode3);
}
}
The code to merge the two already sorted sub-linked lists into a sorted linked list could be
something like this..
mynode * merge(mynode *a, mynode *b)
{
mynode *i, *j, *k, *c;
i = a;
j = b;
c = getNewNode();
k = getNewNode();
while(i!=NULL && j!=NULL)
{
if(i->value < j->value)
{
k->next=i;
i=i->next;
}
else
{
k->next=j;
j=j->next;
}
}
if(i!=NULL)
k->next=i;
else
k->next=j;
return(c->next);
}

Linked Lists

How do you reverse a singly linked list? How do you reverse a doubly linked list? Write
a C program to do the same.
This is THE most frequently asked interview question. The most!.
Singly linked lists
Here are a few C programs to reverse a singly linked list.

Method1 (Iterative)


#include <stdio.h>
// Variables
typedef struct node
{
int value;
struct node *next;
}mynode;
// Globals (not required, though).
mynode *head, *tail, *temp;
// Functions
void add(int value);
void iterative_reverse();
void print_list();
// The main() function
int main()
{
head=(mynode *)0;
// Construct the linked list.
add(1);
add(2);
add(3);
//Print it
print_list();
// Reverse it.
iterative_reverse();
//Print it again
print_list();
return(0);
}

// The reverse function
void iterative_reverse()
{
mynode *p, *q, *r;
if(head == (mynode *)0)
{
return;
}
p = head;
q = p->next;
p->next = (mynode *)0;
while (q != (mynode *)0)
{
r = q->next;
q->next = p;
p = q;
q = r;
}
head = p;
}
// Function to add new nodes to the linked list
void add(int value)
{
temp = (mynode *) malloc(sizeof(struct node));
temp->next=(mynode *)0;
temp->value=value;
if(head==(mynode *)0)
{
head=temp;
tail=temp;
}
else
{
tail->next=temp;
tail=temp;
}
}
// Function to print the linked list.
void print_list()
{
printf("\n\n");
for(temp=head; temp!=(mynode *)0; temp=temp->next)
{
printf("[%d]->",(temp->value));
}
printf("[NULL]\n\n");
}

Method2 (Recursive, without using any temporary variable)

#include <stdio.h>
// Variables
typedef struct node
{
int value;
struct node *next;
}mynode;
// Globals.
mynode *head, *tail, *temp;
// Functions
void add(int value);
mynode* reverse_recurse(mynode *root);
void print_list();
// The main() function
int main()
{
head=(mynode *)0;
// Construct the linked list.
add(1);
add(2);
add(3);
//Print it
print_list();
// Reverse it.
if(head != (mynode *)0)
{
temp = reverse_recurse(head);
temp->next = (mynode *)0;
}
//Print it again
print_list();
return(0);
}
// Reverse the linked list recursively
//
// This function uses the power of the stack to make this
// *magical* assignment
//
// node->next->next=node;
//
// :)
mynode* reverse_recurse(mynode *root)
{
if(root->next!=(mynode *)0)
{
reverse_recurse(root->next);
root->next->next=root;
return(root);
}
else
{
head=root;
}
}
// Function to add new nodes to the linked list.
void add(int value)
{
temp = (mynode *) malloc(sizeof(struct node));
temp->next=(mynode *)0;
temp->value=value;
if(head==(mynode *)0)
{
head=temp;
tail=temp;
}
else
{
tail->next=temp;
tail=temp;
}
}
// Function to print the linked list.
void print_list()
{
printf("\n\n");
for(temp=head; temp!=(mynode *)0; temp=temp->next)
{
printf("[%d]->",(temp->value));
}
printf("[NULL]\n\n");
}

Method3 (Recursive, but without ANY global variables. Slightly messy!)

#include <stdio.h>
// Variables
typedef struct node
{
int value;
struct node *next;
}mynode;
// Functions
void add(mynode **head, mynode **tail, int value);
mynode* reverse_recurse(mynode *current, mynode *next);
void print_list(mynode *);
int main()
{
mynode *head, *tail;
head=(mynode *)0;
// Construct the linked list.
add(&head, &tail, 1);
add(&head, &tail, 2);
add(&head, &tail, 3);
//Print it
print_list(head);
// Reverse it.
head = reverse_recurse(head, (mynode *)0);
//Print it again
print_list(head);
getch();
return(0);
}
// Reverse the linked list recursively
mynode* reverse_recurse(mynode *current, mynode *next)
{
mynode *ret;
if(current==(mynode *)0)
{
return((mynode *)0);
}
ret = (mynode *)0;
if (current->next != (mynode *)0)
{
ret = reverse_recurse(current->next, current);
}
else
{
ret = current;
}
current->next = next;
return ret;
}
// Function to add new nodes to the linked list.
// Takes pointers to pointers to maintain the
// *actual* head and tail pointers (which are local to main()).
void add(mynode **head, mynode **tail, int value)
{
mynode *temp1, *temp2;
temp1 = (mynode *) malloc(sizeof(struct node));
temp1->next=(mynode *)0;
temp1->value=value;
if(*head==(mynode *)0)
{
*head=temp1;
*tail=temp1;
}
else
{
for(temp2 = *head; temp2->next!= (mynode *)0; temp2=temp2-
>next);
temp2->next = temp1;
*tail=temp1;
}
}
// Function to print the linked list.
void print_list(mynode *head)
{
mynode *temp;
printf("\n\n");
for(temp=head; temp!=(mynode *)0; temp=temp->next)
{
printf("[%d]->",(temp->value));
}
printf("[NULL]\n\n");
}

Doubly linked lists

This is really easy, just keep swapping the prev and next pointers and at the end swap the
head and the tail:)
#include<stdio.h>
#include<ctype.h>
typedef struct node
{
int value;
struct node *next;
struct node *prev;
}mynode ;
mynode *head, *tail;
void add_node(int value);
void print_list();
void reverse();
int main()
{
head=NULL;
tail=NULL;
add_node(1);
add_node(2);
add_node(3);
add_node(4);
add_node(5);
print_list();
reverse();
print_list();
return(1);
}
void add_node(int value)
{
mynode *temp, *cur;
temp = (mynode *)malloc(sizeof(mynode));
temp->next=NULL;
temp->prev=NULL;
if(head == NULL)
{
printf("\nAdding a head pointer\n");
head=temp;
tail=temp;
temp->value=value;
}
else
{
for(cur=head;cur->next!=NULL;cur=cur->next);
cur->next=temp;
temp->prev=cur;
temp->value=value;
tail=temp;
}
}
void print_list()
{
mynode *temp;
printf("\n--------------------------------\n");
for(temp=head;temp!=NULL;temp=temp->next)
{
printf("\n[%d]\n",temp->value);
}
}
void reverse()
{
mynode *cur, *temp, *save_next;
if(head==tail)return;
if(head==NULL || tail==NULL)return;
for(cur=head;cur!=NULL;)
{
printf("\ncur->value : [%d]\n",cur->value);
temp=cur->next;
save_next=cur->next;
cur->next=cur->prev;
cur->prev=temp;
cur=save_next;
}
temp=head;
head=tail;
tail=temp;
}

Having shown all these different methods, if someone can mail me a really, really good
practical application of reversing a linked list (singly or doubly linked list), I would be
really thankful to them. I have not found one good application of this. All I see is an urge
to understand how well the candidate handles the pointer manipulation.

Syllabus of HTML

Sunday, 14 September 2014

connnection.php

Connection Code PHP - MySql
Connecton.php Download

Code

<?php

$us="root";  // username
$pwd="";  // password
$ls="localhost"; //host
$db=mysql_connect($ls,$us,$pwd)or die(mysql_error());
$sd=mysql_select_db("mydb",$db)or die(mysql_error());

// mydb - database

?>

Note :  In connection string all requirement will be set by you at the time of installationBy Default username = root, password = " ", Host-address = " localhost ", Database = "Database Name " for example = 'mydb'.

You can download directly connection.php page Click here

Reset.css

Reset.css

How to change the port or VirtualHost for PHP

Why need to change port or VirtualHost

After Completion of Installation -> launch Wamp server -> open Browser
Type -> http://localhost/phpmyadmin/         [by default port = :80]
      or    http://localhost:80/phpmyadmin/


So need to change port number of wamp server 80 to 81/82...etc, in this example change into 81

Goto ->
  •  Taskbar -> Click on Wamp logo -> Apache -> httpd.conf   Or
  •  C:\wamp\bin\apache\Apache2.4.4\conf\httpd.conf
Find in  httpd.conf
  • Listen 80
  • change into Listen 81

How to Export database via PHP My Admin

PHP My Admin -> Export Database in MySQL

  • Lanch the Server -> Wamp / Xampp
  • Taskbar -> click the logo of Wamp -> phpmyadmin  Or
    Open browser -> http://localhost/phpmyadmin  Or
    Open browser -> http://localhost:[port-no]/phpmyadmin
  • Select existing Database
    SQL - used <database-name>;
  • export -> save in ".sql" ->  GO

How to Import database via PHP My Admin

PHP My Admin -> Import Database in MySQL


  • Lanch the Server -> Wamp / Xampp
  • Taskbar -> click the logo of Wamp -> phpmyadmin  Or
    Open browser -> http://localhost/phpmyadmin  Or
    Open browser -> http://localhost:[port-no]/phpmyadmin
  • Create Database -> Select Database
    SQL - create database <database-name>;
    Select existing Database
    SQL - used <database-name>;
  • import -> Browse_  -> Choose the file [.sql file ] ->  GO

NOTE :- if at the time of Export the Database or Back_up of Database check the select item is Database/Table

Free online data storage sites: Store upto 25GB of data

It is always safe to store your data online as it can be accessed anywhere. Generally we have lots of data stored in hard drive. Now a days HDD are very cheap so you may think that why to store data online. 
Advatage :- 
  • If anything happens to hard drive, you will loose your whole useful data, it can get lost or can crash anytime.
  • It can be accessed anywhere.
  • It is secured.
Better solution to avoid any issues, is to have your important data stored online.In this article I will share free online data storage sites, where you can save hell lot of data.


SkyDrive


Microsoft skydrive offers 15GB free online storage and you can guess it service and popularity by yourself as it is an Microsoft website .


  • Desktop syncing 
  • Mobile access
  • Create/edit Office documents in a browser
  • Built in integration with Office desktop
  • Real time co-authoring on Office documents
  • Automatic versioning and history of documents
  • Multifactor authentication support 

DropBox




Any file you save to Dropbox also instantly saves to your computers, phones, and the Dropbox website.
  • Starting at 2 GB for free and up to 16 GB with referrals.
  • Pro accounts with up to 500 GB. Business accounts start at 1 TB for 5 users.
  • Your files are always available from the secure Dropbox website.
  • Dropbox works with Windows, Mac, Linux, iPad, iPhone, Android and BlackBerry.
  • Works even when offline. You always have your files, whether or not you have a connection.
  • Dropbox transfers just the parts of a file that change (not the whole thing).
  • Manually set bandwidth limits -- Dropbox won't hog your connection.

FlipDrive

All your data is stored in the cloud - in one convenient and secure online location, and available to you anytime, anywhere, from any device.


Share anything with anybody - on your own terms. Easily share large files which are too big for email and share entire folders. Concerned about privacy? So are we! Keep your data private and away from unwanted eyes, and share it privately with select group of people, set access permissions to give limited access to critical data.

Jumptuit

Jumptuit provides 30GB of free online storage which is very very Good. If you compare it with other free online data storage sites then you would definitely find it good, as most of other  sites allows you to store maximum 5GB of data for free.It is very popular and much appreciated data storage site.



Google Drive

Google Drive is a file storage and synchronization service provided by Google, released on April 24, 2012, which enables user cloud storage, file sharing and collaborative editing. Files shared publicly on Google Drive can be searched with web search engines. As of June 2014, Google Drive had 190 million monthly active users. Google Drive is the home of Google Docs, Sheets and Slides, an office suite of productivity applications, that offer collaborative editing on documents, spreadsheets, presentations, drawings, forms, and more.

Saturday, 13 September 2014

Website PNG Icon Collection

web-icon_collection Download

web-icon_collection Download

web-icon_Sweets Download

bwpx-icon Collection Download

50 icons set from  Download


Once_by_Delacro Official Link Download


web-icon_collection Download

Indo Web-icon_collection Download

Local-web-icon Download

Max-min-web-icon Download

Web application - icon Download

Sunday, 7 September 2014

Comments in PHP

In PHP, we use // to make a single-line comment or /* and */ to make a large comment block.

Example of single line Comment

<html>
<body>
<?php
//This is a comment
?>
</body>
</html>


Multi - line Comment

Example of Multi - line Comment

<html>
<body>
<?php
/*
This is a comment block
*/
?>
</body>
</html>


Advantages of Comment

Comments are not displayed by the browser, but most of the Designer and Developer using this Comment(single-line or multi-line comment) for Future Implementation.
With comments you can place message, code, notifications and reminders in your PHP Document. Comments are also great for debugging PHP or in any Language, because you can comment out PHP lines of code, at a time, to search for errors.

PHP Syntax

PHP code is executed on the server, and the plain HTML result is sent to the browser.
Basic PHP Syntax
A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document. On servers with shorthand support enabled you can start a scripting block with <? and end with ?>. For maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form.

Basic PHP Syntax

<?php

// statement ;

?>


A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code. Below, we have an example of a simple PHP script which sends the text "Hello World" to the browser:

Basic PHP Syntax

<html>
<body>

<?php
echo "Hello World";
?>

</body>
</html>


Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another. There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World".
The file must have a .php extension. If the file has a .html extension, the PHP code will not be executed.

How to setup wamp server in windows OS


  • Download the Wamp Server

  • Install the Downloaded file
  •  Search Wamp and Open [follow 1st Image] 
  • Click on aero UP, right side in the task bar
  • Right click on "W" icon and Put Online [follow 2nd Image]

  • Restart the Wamp Server
  • Open the Browser [ like :- Firefox, Crome, Opera, Safari, Netscape, Comodo Dragon,...]
    Type in URL "localhost:80" or "localhost" if server is setup successfully [follow 3rd Image].
  • Enjoy....

PHP Introduction



PHP is a server-side scripting language.  

What is PHP?
  • PHP stands for PHP: Hypertext Preprocessor
  • PHP is a server-side scripting language, like ASP
  • PHP scripts are executed on the server 
  • PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.) 
  • PHP is an open source software 
  • PHP is free to download and use 
What is a PHP File?
PHP files can contain text, HTML tags and scripts
PHP files are returned to the browser as plain HTML
PHP files have a file extension of ".php", ".php3", or ".phtml"

Why PHP? 
PHP runs on different platforms (Windows, Linux, Unix, etc.)
PHP is compatible with almost all servers used today (Apache, IIS, etc.)
PHP is FREE to download from the official PHP resource: www.php.net
PHP is easy to learn and runs efficiently on the server side

Where to Start?
To get access to a web server with PHP support, you can
Install Apache (or IIS) on your own server, install PHP, and MySQL
Or find a web hosting plan with PHP and MySQL support
This post is related to navigation :- Very low wait navigation example, only by HTML and CSS basics
HTML Code
CSS Code
How to download
http://filepi.com/i/bQ8CoyT

Wednesday, 3 September 2014

Design Paging section via HTML and CSS

HTML Code

CSS Code

Snap Shot

HTML Introduction


Html stands for "Hyper-Text Markup Language. This is the language that Web pages are written in. Also known as hypertext documents, Web pages must conform to the rules of HTML in order to be displayed correctly in a Web browser. The HTML syntax is based on a list of tags that describe the page's format and what is displayed on the Web page.


What is HTML?

HTML is a markup language for describing web documents (web pages).

  • HTML stands for Hyper Text Markup Language
  • A markup language is a set of markup tags
  • HTML documents are described by HTML tags
  • Each HTML tag describes different document content

Basic Structure of HTML

<html>
<head>
<title> Html Tutorial </title>
</head>
<body bgcolor="yellow">

  <h1>
My first website. </h1>
<h2>
My first website. </h2>
<p>
My first website. </p>
</body>
</html>

Why HTML?

HTML is used in the creation of web pages. The HTML language marks up the data returned from the server, is read by the browser, and rendered. HTML isn't a programming language, but it is part of a group of languages called "mark-up languages" that are widely used for a variety of tasks.

Extension

.html


.htm