IPB
Your FREE membership includes:
  • A friendly community where you can come to chat
  • Receive completely FREE quality web hosting!
  • Get reviews and suggestions for your websites!
  • Take part in competitions where you can win prizes from cash, vouchers, or win special unadvertised hosting

Welcome Guest ( Log In | Register )


Shortcut links:
Like this topic? Digg it... Digg this topic · Save to del.icio.us · Slashdot It · Post to Technorati · Post to Furl · Submit to Reddit · Share on Facebook · Fark It · Googlize This Post · Add to ma.gnolia · Tag to Wink · Add to MyWeb · Add to Netscape
 
Reply to this topicStart new topic
> PHP + MySQL Tutorial
Nishi
post Sep 22 2006, 04:00 AM
Post #1


Member
Group Icon

Group: Members
Posts: 647
Joined: 18-September 06
Member No.: 1



To start with PHP, you need to understand a little about how it works.

Normal web pages store HTML which looks like this:



Code:
<html>
<head>
<title>Page title</title>
</head>
<body>
Page body
<h1>Header</h1>
<p>Paragraph</p>
<center>The time on the server is now 06:06:06 on 06-Jun-06.</center>
</body>
</html>
But the proble is this page is static, which means the text in it cannot change, so for example if I want to show the actual time on the server, I would need to keep on editing the page!

To allow me to do that, I need for the web page to be generated dynamically on the fly when it is accessed so that I can put the right date/time. I can use PHP to do that, because it allow me to put some instructions in the middle of the HTML that will dynamically do something, like print the current time.

So that can be done thus:

Code:
<html>
<head>
<title>Page title</title>
</head>
<body>
Page body
<h1>Header</h1>
<p>Paragraph</p>
<center>The time on the server is now <?php echo date(DATE_RFC822); ?>.</center>
</body>
</html>

Ok, so now you notice that we have replaced the static date/time text with <?php echo date(DATE_RFC822); ?>. We will also need to change the name of the file to be .php rather than .html. This tells the web server that there is PHP code inside the page that must be further interpreted to generate the final HTML before the page can be sent to the requesting web browser client.

So, let us look at the PHP code:
<?php - this tells the web server that PHP code follows and so it is properly interpreted by the PHP interpreter.

echo date(DATE_RFC822) - tells PHP to print (echo) the date in RFC822 format (the old Unix format.)

; - instructions are terminated with a semicolon

?> - closes the <?php part and says to the PHP interpreter that this is the end of the PHP code and the rest is HTML so it should be left un touched.

So this is it for the very basics of PHP.

A couple of other tips:

1. comments are: /* and */ pair or // to end of line or even # to end of line
2. variables are: $var_name
Go to the top of the page
 
+Quote Post
badboy7862
post Sep 22 2006, 09:58 AM
Post #2


Starter Member
Group Icon

Group: Members
Posts: 35
Joined: 22-September 06
Member No.: 18



this is good to get started with


--------------------
IPB Image
IPB Image
IPB Image
Go to the top of the page
 
+Quote Post
Gunner54
post Sep 22 2006, 03:35 PM
Post #3


Newbie


Group: Members
Posts: 22
Joined: 22-September 06
Member No.: 19



Nice tut i could really do with this for when i want to make a php file, good to start with
Go to the top of the page
 
+Quote Post
gamescoper
post Sep 29 2007, 10:23 AM
Post #4


Starter Member
Group Icon

Group: Members
Posts: 43
Joined: 29-September 07
Member No.: 1128



too late for me i am already being known as a really good php programmer


--------------------
Go to the top of the page
 
+Quote Post
abhayks
post Sep 29 2007, 11:06 PM
Post #5


Newbie


Group: Members
Posts: 14
Joined: 29-September 07
Member No.: 1130



This is basic, actually very basic.
We get much more resources on net and much elaborate tutorials.
PHP is an easy language and does not require too much to learn.
Go to the top of the page
 
+Quote Post
schumacher
post Oct 4 2007, 07:45 AM
Post #6


Starter Member
Group Icon

Group: Members
Posts: 86
Joined: 12-January 07
Member No.: 491



Nice tutorial but theres heaps of good ones on the web as well:

The W3 schools is very useful it explains things in clear English:
http://www.w3schools.com/php/default.asp

Also try the actual php manual website. This lists everything about PHP including syntax, but some of the examples can be a bit complex if your new to php.
http://www.php.net/manual/en/
Go to the top of the page
 
+Quote Post
timothyescopete
post Oct 13 2007, 12:25 AM
Post #7


Starter Member
Group Icon

Group: Members
Posts: 36
Joined: 12-September 07
Member No.: 989



QUOTE(schumacher @ Oct 4 2007, 08:44 PM) *
Nice tutorial but theres heaps of good ones on the web as well:

The W3 schools is very useful it explains things in clear English:
http://www.w3schools.com/php/default.asp

Also try the actual php manual website. This lists everything about PHP including syntax, but some of the examples can be a bit complex if your new to php.
http://www.php.net/manual/en/


I really learned a lot out from these websites. I have done our school's discripline office' program that records all students violations and etc and also an accounting system of one of the cooperative in our school. it is really great. all with personal studies and motivations. BTW< i AM a political science student and php, mysql and etc etc etc has nothing to do with my course, but I know them.
Go to the top of the page
 
+Quote Post
timothyescopete
post Oct 13 2007, 12:37 AM
Post #8


Starter Member
Group Icon

Group: Members
Posts: 36
Joined: 12-September 07
Member No.: 989



QUOTE(timothyescopete @ Oct 13 2007, 01:24 PM) *
I really learned a lot out from these websites. I have done our school's discripline office' program that records all students violations and etc and also an accounting system of one of the cooperative in our school. it is really great. all with personal studies and motivations. BTW< i AM a political science student and php, mysql and etc etc etc has nothing to do with my course, but I know them.


.... I know them more than a computer science major here in our university and even computer engineerings...
Go to the top of the page
 
+Quote Post
WorldEvolution
post Oct 15 2007, 11:46 AM
Post #9


Starter Member
Group Icon

Group: Members
Posts: 55
Joined: 14-October 07
Member No.: 1177



Nice Tut. I'm Trying To Learn php i already know java.
Go to the top of the page
 
+Quote Post
javayahtzee
post Oct 20 2007, 07:58 PM
Post #10


Professional
Group Icon

Group: Members
Posts: 538
Joined: 20-October 07
Member No.: 1199



Nice simple php tutorial.


--------------------
Go to the top of the page
 
+Quote Post
testtorrent
post Dec 8 2007, 08:56 AM
Post #11


Newbie


Group: Members
Posts: 10
Joined: 8-December 07
Member No.: 1294



QUOTE(Admin @ Sep 22 2006, 04:00 AM) *
To start with PHP, you need to understand a little about how it works.

Normal web pages store HTML which looks like this:
Code:
<html>
<head>
<title>Page title</title>
</head>
<body>
Page body
<h1>Header</h1>
<p>Paragraph</p>
<center>The time on the server is now 06:06:06 on 06-Jun-06.</center>
</body>
</html>
But the proble is this page is static, which means the text in it cannot change, so for example if I want to show the actual time on the server, I would need to keep on editing the page!

To allow me to do that, I need for the web page to be generated dynamically on the fly when it is accessed so that I can put the right date/time. I can use PHP to do that, because it allow me to put some instructions in the middle of the HTML that will dynamically do something, like print the current time.

So that can be done thus:

Code:
<html>
<head>
<title>Page title</title>
</head>
<body>
Page body
<h1>Header</h1>
<p>Paragraph</p>
<center>The time on the server is now <?php echo date(DATE_RFC822); ?>.</center>
</body>
</html>

Ok, so now you notice that we have replaced the static date/time text with <?php echo date(DATE_RFC822); ?>. We will also need to change the name of the file to be .php rather than .html. This tells the web server that there is PHP code inside the page that must be further interpreted to generate the final HTML before the page can be sent to the requesting web browser client.

So, let us look at the PHP code:
<?php - this tells the web server that PHP code follows and so it is properly interpreted by the PHP interpreter.

echo date(DATE_RFC822) - tells PHP to print (echo) the date in RFC822 format (the old Unix format.)

; - instructions are terminated with a semicolon

?> - closes the <?php part and says to the PHP interpreter that this is the end of the PHP code and the rest is HTML so it should be left un touched.

So this is it for the very basics of PHP.

A couple of other tips:

1. comments are: /* and */ pair or // to end of line or even # to end of line
2. variables are: $var_name


yes man i like this tutorial thank's
Go to the top of the page
 
+Quote Post
aungcho
post Aug 5 2008, 11:04 PM
Post #12


Advanced Member
Group Icon

Group: Members
Posts: 218
Joined: 17-October 06
From: Myanmar
Member No.: 69



Short and simple one. Although it is really a basic one, very useful to one who doesn't know this function and constant.


--------------------
Go to the top of the page
 
+Quote Post
iespace
post Aug 10 2008, 08:11 AM
Post #13


Starter Member
Group Icon

Group: Members
Posts: 87
Joined: 10-August 08
Member No.: 1780



I know php,mysql a litter.
Go to the top of the page
 
+Quote Post
sam06
post Nov 10 2008, 04:56 PM
Post #14


Starter Member
Group Icon

Group: Members
Posts: 155
Joined: 15-November 06
Member No.: 179



http://www.tizag.com is good for a lot of langauges.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are browsing this forum (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    T