PHP-MySQL Book.pdf. PHP-MySQL Book.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying PHP-MySQL Book.pdf.
Web Trainings Institute
PHP & MySQL
1
Web Trainings Institute
Table of Contents Installation Introduction PHP and MySQL PHP Installation MySQL Installation Apache Installation Configuring and Testing software’s. XAMPP and WAMPP Installation
PHP Basics
Embedding PHP in HTML Embedding HTML in PHP Introduction of Variable Using variables Understanding > Q: This creature can change color to blend in with its surroundings. What is its name? 17
Web Trainings Institute
Comments in PHP
Variables Variables are the building blocks of any programming language. A variable can be thought of as a programming construct used to store both numeric and nonnumeric > Q: Where can we learn php in hyderabad. What is the name of institute? 18
Web Trainings Institute
Assigning and Using Variable Values To assign a value to a variable, use the assignment operator, the equality (=) symbol. This operator assigns a value (the right side of the equation) to a variable (the left side). The value being assigned need not always be fixed; it could also be another variable, an expression, or even an expression involving other variables, as here: To use a variable value in your script, simply call the variable by name, and PHP will substitute its value at run time. For example:
Saving Form Input in Variables Forms have always been one of the quickest and easiest ways to add interactivity to your web site. A form enables you to ask customers if they like your products and casual visitors for comments. PHP can simplify the task of processing webbased forms substantially, by providing a simple mechanism to read user method="post"> Enter your message: The most critical line in this entire page is the tag: ... As you probably already know, the method attribute of the tag specifies the manner in which form ; $cars[1]="Volvo"; $cars[2]="BMW"; $cars[3]="Toyota";
34
Web Trainings Institute
Example In the following example you access the variable values by referring to the array name and index: The code above will output: Saab and Volvo are Swedish cars.
Associative Arrays An associative array, each ID key is associated with a value.When storing method="POST"> Power steering Rear windshield wiper 6 CD changer Fog lamps Central locking Computer-based navigation Notice in this script that the name of the control contains the square braces used when defining a PHP array. The result is this: when the form is submitted, PHP will automatically create an array variable to hold the selected items. This array can then be processed with a foreach() loop, and the selected items retrieved from it. Creating User-Defined Functions A function is simply a set of program statements that perform a specific task, and that can be called, or executed, from anywhere in your program. Every programming language comes with its own functions, and typically also enables developers to define their own. For example, if you had a series of numbers, and you wanted to reduce each of them by 20 percent, you could pull out your calculator and do it manually . . . or you could write a simple PHP function called cheatTheTaxman(), send it the numbers one by one, and have it do the heavy lifting for you. Defining and Invoking Functions To understand how custom functions work, examine the following script: 43
Web Trainings Institute
Reading and Writing files in PHP PHP follows almost same way of writing and manipulating files as in standard C. That is why it becomes so easy for a developer with C lanaguage background to create php application that uses files to save and retrieve >