Monday, April 11, 2011

PHP Tutorials, script to connect to the MySql database

This script is used for connection to the database MySQL. The first is that we must know the host, username, and password to connect to MySql. By default host is "localhost" and the username is "root". For the password depends on when you install the program to your database. such appserv, xampp, wampp. just this php script to connect to the database.  

<? php 
mysql_connect ("localhost", "root", "password"); 
mysql_select_db ("MyDatabase"); 
?>  

script above for a password can be changed according to the password for your database. and "MyDatabase" above is the name of the database that you created with MySQL or phpMyAdmin. To try the script above we can write like this. 

<? php  
$query = mysql_connect ("localhost", "root", "password");  
mysql_select_db ("MyDatabase"); 
if ($ query)  

 echo "successfully connect to database "; 
}  
else 
{ 
echo "can not successfully connect to the database "; 
}
?>  
then save this file with a name like" connect.php ". ooo you can write this in notepad, edit + +, or Dreamweaver. Good luck.   By Ardian

Wednesday, March 16, 2011

Basic CSS

Designing without tables by using CSS layouts is fast
becoming the new standard on the Web because of the
benefits mentioned in my previous article. Web browsers
used these days are now able to render web pages
proficiently. In this article I will endeavor to create a
basic 2 column CSS layout which you can use for future
design projects.
Web Page: http://www.isitebuild.com/css/css-layout.html
Style Sheet: http://www.isitebuild.com/css/stylesheet.htm
1. Divide your page into sections - the div id tags
allows you to create distinct divisions on your web page.
They are identified with a unique id. You can then add a
style (css selector) that specifically applies to the div
of that id. Remember to include the DOCTYPE (to render your
page accurately in the browsers) and meta tags (enables
search engines to spider your pages).
wrapper: is the div that wraps around all the other divs
like a container for the page elements.
header: defines the top banner of the page
main: defines the main content of the page
nav: defines the navigation of the page
footer: defines the footer and sub-navigation of the page
2. Create the CSS code - the CSS code styles the page as a centered 2 column CSS layout with a navigation bar and a footer. The div#wrapper style creates the centered box which acts as a container for the rest of the page content. The width: 80% rule sets the width of the div. The background-color:#FFFFFF rule creates a white background for the div. The margin-top: 50px and
margin-bottom: 50px rules create a space of 50 pixels for
the top and bottom margins for the div itself.
The proper way to center a block-level element with CSS is
to set margin-left: auto and margin-right: auto. This
instructs the browser to automatically calculate equal
margins for both sides, thus centering the div. The border:
thin solid #000000 rule adds a border around the outer div.
The rest of the CSS code styles the divs for the header,
footer, nav, and main content.
The div#header and div#footer styles set margins and
padding for those divs. In addition, div#header includes
the text-align: center rule to center the header text, and
div#footer includes the border-top: thin solid #000000 rule
to create a border along the top edge of the div to replace
the horizontal rule above the footer in the table-based
layout.
The div#nav and div#main styles create the two columns in
the middle of the centered box. In the div#nav style, the
float: left rule pushes the div to the left side of its
parent element (the wrapper div), and the width: 25% rule
sets the div's width to 25 percent of the parent element.
With the nav div floated to the left and limited to a set
width, it leaves room for the main div to move up to the
right of the nav div, thus creating the two-column effect.
The div#main style includes the margin-left: 30% rule to
keep the main text aligned in a neat column instead of
spreading out below the nav column. The main div's left
margin is set to a value slightly larger than the width of
the nav div.
Style Sheet
http://www.isitebuild.com/css/stylesheet.htm
If links are placed elsewhere on the page they will inherit
the same properties as above..a blue link that hovers to
red. What if you wish to create another set of links that
are a different color and on passing your mouse over them
they are underlined.
4. Create the bottom navigation - to include this in the
section of the page, I use div#footer and
code each link accordingly. To make the list go
horizontally I use: display: inline;
Now that I have finished creating my style sheet I want to
shorten the code on page by linking it to my external style
sheet. Here's how:
4. Create an external style sheet - copy and paste all the
css code (without these tags: ) into notepad and label it something like
"style sheet". Place this style sheet between the head tags
of your web page.
This will reduce the code on your page so it will load fast
plus the search engines can more easily spider your web
page.
4. Add content to your page - after you have got your page
looking correctly, you can add more content to it.
Adjustments can easily be made to any style on the page (or
your whole site) by simply editing one style sheet.
5. Upload your files - be sure to upload your web pages and
style sheet to the root directory of your server.
6. Validate your code - be sure to validate your xhtml
code: http://validator.w3.org/ and css code:
http://jigsaw.w3.org/css-validator/ and make corrections
where necessary.
7. Check browser compatibility and screen resolution -
check that your page renders well in the popular browsers
(IE6, NN7, Firefox)
If you are beginning with CSS layouts, implement then
slowly by making small changes to your pages i.e. creating
a style sheet for your main headers and fonts only. As you
become more familiar with CSS you may eventually build all
your future sites with CSS layouts.
Resources:
Basic CSS layout
http://www.isitebuild.com/css/css-layout.html
CSS Style Sheet
http://www.isitebuild.com/css/stylesheet.htm
Benefits of CSS
http://www.isitebuild.com/css/index.htm

Javascript Programming

Static v Dynamic
JavaScript can do more than HTML because HTML is static, but JavaScript is dynamic, which means that it can react to viewer actions, such as clicking or rolling the mouse over an object. JavaScripts are often called "behaviors." A behavior is made up of a viewer "event" and a response or "action" by the programming. You can program a behavior to happen when a viewer clicks, or you can program it to happen when the viewer double clicks - that is the "event." When the "event" happens, the programming responds by showing something, like a drop-down menu, or by doing something, like playing a sound. With JavaScript, you site is "dynamic" because it responds to your viewer beyond regular hyperlinks!
Client-side programming v Server-side programming
JavaScript is a "client-side" programming language. Client-side means that the program code is sent into your computer with the rest of the web page code (usually HTML); then, your browser reads the code and does what it says. That means that on many sites with JavaScript, you can look at the programming code right along with the HTML by going to Edit -> View Source in your browser. You can usually tell if the code has JavaScript in it because the head tag will have a like that says script language="JavaScript". That is a good way to look at some working scripts. (Some websites do hide their JavaScript coding.)
JavaScript and Browsers
JavaScript is frequently used to do simple programming tasks because web viewers can turn JavaScript off on their computer, which means that all your hard programming work doesn't function when they view your site. JavaScript may be turned off for security, and there have been browsers that have JavaScript disabled as a default setting. Instead, we use JavaScript to enhance the functionality of a web page. For example, if you completely rely on JavaScript to validate your online forms, you have a security hole. If a viewer's JavaScript is turned off, it will by-pass your validation. So, you may also use a "server-side" programming language to double check the input.
Newer browsers generally have newer versions of JavaScript, which means there are more programming options. Some old browsers can't read JavaScript, or they can only read limited amounts of JavaScript. A browser that is JavaScript enabled can read some version of JavaScript.
Other Options
There are other types of scripting that look a lot like JavaScript. For example, the Flash program has its own scripting language called ActionScript, and many of the effects it produces in Flash are similar to what JavaScript can do on a page. For example, you can create a set of rotating images in JavaScript. The same thing can be done in Flash, except the Flash action is generally much smoother. If you learn JavaScript, you have the basics to start on many other scripting languages that are used for web pages.
Give it a try
You don't have to be Super-Geek to learn a little JavaScript! Here is a link to a few simple JavaScript exercises. All you need to do these exercises is Notepad (or another text editor  - do not use a word processor as the files may not be readable by the browser) and a browser. http://www.thecomputergal.com/Programming/JavaScript/8-HourSyllabus.htm
If you have never worked in HTML code before, read this page first to understand the steps of working between your text editor and your browser: http://www.thecomputergal.com/WebDesign/Lessons/UsingTextEditorSteps.htm
These materials are used in the 8-hour JavaScript course at Dickinson Lifelong Learning Center in Missoula, MT
Nora McDougall-Collins
Missoula, MT
Putting the world of computers into plain English

All about Jquery

Recently I experimented with a jQuery event calendar on our Booking System. Our previous version uses ASP.NET to build the booking chart as a whole on the server and then renders the lot to the browser. It was a bit slow and clunky, but worked.
I wanted to have a PHP version of the Room Booking System so did a quick port from the ASP.NET C# to PHP, and then I dropped the jQuery fullcalendar component on the page. I used a web service for the data which was still written in C# against a Microsoft SQLServer database.
On a little more tinkering and refactoring, I found I could get rid of almost all the PHP/.NET code as it was only used to initialise the page. Now I was left with a page with effectively just HTML and JavaScript using a AJAX to call a JSON data feed from a REST web service.
The effects were stunning! Besides looking nicer, the speed of update was incredible - like a Windows application. Of course, this is achieved because the page runs almost entirely in the browser and calendar navigation may request just small amount of data using AJAX against the web service.
Could I write the entire application like this?
It reminded me of programming in the 1990's. Web pages were HTML with a bit of JavaScript; we then added a little ASP to get data from a database and stick that on the page. Getting data on a page was relatively easy even then; the problem has always been when we want the user to interact with it. Even the simple stuff, like only allowing a numeric digit into a text box, checking for valid date, data grids or even simple popups were not as easy as in a Windows app.
Why? Because pure JavaScript is slow to write, it's easy to make mistakes, difficult to debug and you're at the mercy of whichever browser the user has preference for.
Programmers looked for other means and found them in applets, DLLs,.NET, JSF and other technologies and server frameworks. I moved on to ASP.NET because it took the drudgery out of programming, automatically generated the JavaScript and was easy to write and debug; a much friendlier model. It still is, but jQuery and other JavaScript Frameworks are now threatening the status quo.
Microsoft has adopted jQuery in a big way and it will replace the AJAX Toolkit. Many software developers have already adopted jQuery or YUI. Combined with HTML5, these JavaScript Frameworks may pressurise Flash and Silverlight. jQuery certainly has a place in the near future of web development
Can I just use jQuery and nothing else? Maybe - but not yet, not entirely. As impressed as I am with jQuery, I feel it's just one of the tools in the software developer's toolbox. I'll use jQuery more and more but I'll be using.NET and PHP too. Here's how I summarise it:
For and Against jQuery and JavaScript Frameworks
FOR:
  • Good User Experience, close to a Windows GUI
  • Much easier to use than plain JavaScript
  • Impressive speed
  • Coders don't have to worry about Browser differences
  • Reduces Server Load as fewer round-trips
  • Widely used, good community support
  • Many components already developed
  • Open Source
AGAINST:
  • You probably still need a Server framework for initialisation and Session management
  • You need another app to supply your data (like a web service) written in another language (like.NET, Java or PHP)
  • In larger apps, slower to code than PHP or ASP.NET
  • You need to understand CSS
  • Can still be difficult to debug, especially if scripts interfere with each other.
  • Source code is difficult to protect
  • Can be a little cryptic to read
If you haven't tried jQuery then you should definitely do so. It's easy to get into and will enhance your web applications
Les Kendall blogs at http://www.makeITspendIT.com and is a director of Cyberforth Limited ( http://www.cyberforth.com/ ), a software company based in England that offers Room Booking Systems, Bespoke Software development services and business solutions.

The Power of Ajax

It's a latest trend that most of the websites bring created nowadays use Ajax programming since it brings parity for the users in the online space. It also introduces a much needed dose of advancement as it offers neat navigation to the website. Google Maps, Yahoo Maps etc. are all based on Ajax.
When the discussion about Ajax takes place, most experts praise Ajax for its great flexibility quotient. Asynchronous JavaScript and XML, better known as Ajax, since its introduction long back in 2005 has been catching eye balls for its remarkable attributes and characteristics. As it gets along well with server-side scripts, it has high-end communication characteristic, and data can be sent or received by Ajax in multiple formats including text, HTML, XML etc.
With Ajax programming, even without refreshing and reloading the web page, you can still send data across the Web. Hence, rich applications can be built using Ajax programming. No wonder why Ajax is the favorite programming language of Ajax web programmers! Also, this trait of Ajax helps users save a considerable amount of time and bandwidth. It's not that the evolution of Ajax has taken place all of a sudden. In fact, it has evolved as a group of web development technologies.
As the market conditions are continually changing with each passing day, the interactions need to be quick and responsive. Hence, the intricate needs related to web design applications are resolved using Ajax programming. As it's a cross-platform technology, it can be used across varied browsers, OS and other architectures. By virtue of these characteristics, it can be effectively used for creating Web 2.0 sites. Many famous websites powered with rich and interactive applications are based on Ajax today.
It certainly has an edge over other traditional web development technologies since pages get reloaded quicker, improved graphic capacities, specific elements reloading, cross-platform technology and usage of varied operating systems.
A good number of Ajax programmers across the world have attained exhaustive knowledge about Ajax programming, and lend their specialized services to businesses, big or small, worldwide.
Let's talk about an example, Google Maps. Most of us have heard about it since it's a big name in the online arena. Its fast loading helps the users to go through the maps with great ease. So, it may prove to be a good business decision if you wish to develop a website backed with user-friendly web applications.
Adam George is a well known writer. He has written many articles on various topics including outsourcing, Presently writing on Software services, Software Development, Ajax Programmers and other Software testing services.

Simple PHP for Beginners

PHP, if you are total computer neophyte like me, stands for "Hypertext Preprocessor," and it is used for embedding HTML scripting to construct vibrant Web pages. What it does for your Web pages is to improve your web interactivity, and this in turn will greatly increase your website usability. Putting this in terms we'll all understand, what it does is to super power your conversion rates and sales!
Once you have learned the secrets to Simple PHP in this book, you will be able to:
• Straightforwardly personalize your own pages.
• Create simple.htaccess code used for yourself.
• Encode quizzes, games, as well as other lead-building tools.
• Create your own autoresponder.
• Combine PHP with JavaScript for a truly awesome combination.
If you know just a tiny bit about computer languages, you will think to yourself "strange, there are literally thousands of totally free PHP scripts available on the Internet, why bother reading this dude's book?" Because my friend, it's not having the codes that makes the difference, it's knowing how to install them, that's the trick!
Whoaa, you may say, you forget that I do not have a Master's degree in computer science! Guess what? You don't need one to read and thoroughly understand what this author is trying to tell you. It's all been broken down in plain simple English. This downloadable manual covers:
• 17 different "newsletter-style" chapters.
• 148 pages in all so that everything gets explained easily.
• Examples of the source code you will need - 22 working snippets!
• After-chapter quizzes in order to actually test your skills.
• Maximize learning by taking the weekly assignments.
In addition, there is a full money back 90-day guarantee. Thus if you're not satisfied, you get your money back, quickly and simply.
In addition to this Simple PHP book, you will also receive:
• NameRazor - an astounding generator of program names for your newly created programs, web sites, or infoproducts
• Essential Video Tutorials - that will show you step-by-step installation of your own PHP and CGI scripts onto your server. This consists of in excess of 108 minutes of special coaching videos that will allow you to:
a. Generate MySQL databases from Cpanel
b. Populate the MySQL databases by using 'myPHPadmin'
c. Upload files using ftp client such as with SmartFTP.com
d. Change the permissions/mode files while simply using ftp client
e. Create and delete files/folders while only using ftp client
f. Edit your configuration files of various scripts
g. Run your setup procedures of scripts
h. Set up the cron job from Cpanel
i. 'Pipe the email' in order to be able to accept email subscriptions


If you are like many other web developers you may have wondered what all the hype is about PHP or MySQL programming. This is a very important question and the reason is this is all the programming that goes on behind the scenes of a website. Most of what PHP is cannot be seen, but the coding is vital to the way the website or process of the website works. Understanding how the process works and learning how to write PHP can be fun and exciting. If you have been looking for a way to learn PHP online, the time has come.
PHP for beginners is a new and educational way to learn what PHP is all about, and how you can incorporate this effective technique into your design capabilities. In this article we will discuss a little about PHP and how you too, can learn this incredible code. PHP beginner's tutorial can open a path for you and allow you to understand the information quickly and efficiently.
The back end code of a website is what separates the amateur sites from the professional sites. Most amateur sites are still running a majority of processes with JavaScript, and this has left holes in their processing and ways to effectively distribute information. PHP back-end code handles functionality of your website for items such as logins, mail forms, and many other functions that are controlled with programming scripts like JavaScript or PHP. The important part of learning this code is your ability to utilize these tools and modify them to work on your site as you need them to.
You might be asking yourself, "Why learn PHP?" and the answer to that question is pretty simple. Online there are a ton of freelance programmers that could create code for you or your website, the only problem is, you don't know these people and they surely don't know you or care about the future of your website. If you could learn PHP for beginners and how it works, you could prevent your website from having security issues in the future, as well as being able to modify processes and enhance features that affect the way programs work on your site.
Once you learn PHP online you will learn how to develop code that can run calculations, collect valuable date, and be able to analyze different bits of data, making PHP coding a vital and integral component to your website. While being very similar to HTML in some ways, you can create code that when completed or assembled will allow multiple changes across many different sites or pages with very easy timely changes. Almost close to what CSS can do to control content on any particular site, PHP code allows for quick and easy changes to content or the layout of a site. PHP can add new levels of customization and functionality to html or other markup languages as well.
PHP beginner's tutorial doesn't require special programs or tools to be coded because you can use a simple text editor as you master design tool. There are some different tools that can be used to tell you if the syntax you have written is off, or can help with prompting for functions or values, but for the most part a simple text editor is all you'll need for writing scripts for web applications.
To get started learning the basics for PHP, is done simply by understanding the time you need to devote to yourself to learn it. If you want to learn PHP online, you can start today. Once you have made the decision, simply jump right in.