LAMP (Linux, Apache, MySQL, PHP)
LAMP is an open source Web development platform that uses Linux as the operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language. (Sometimes Perl or Python is used instead of PHP.)
Because the platform has four layers, LAMP is sometimes referred to as a LAMP stack. Stacks can be built on different operating systems. Developers that use these tools with a Windows operating system instead of Linux are said to be using WAMP; with a Macintosh system, MAMP; and with a Solaris system, SAMP.
The LAMP platform consists of four components that are structured in a layered way. Each layer provides a critical part of the entire software stack:
MySQL
If you are asking yourself what makes the information on the websites so well organized and dynamically generated as we browse through the separate web pages, executing various click, select, download, etc. actions, the answer is simple - the databases. A database is a structured collection of data. The content of the database can be anything from a cooking recipe to a image gallery or the vast amounts of information in a corporate network. To add, access, and process data stored in a computer database, you need a database management system. Since computers are very good at handling large amounts of data, database management systems play a central role in computing, as standalone utilities, or as parts of other applications. To add speed and flexibility, relational database management systems (RDBMS), such as MySQL, store data in separate tables rather than putting all the data in one big storeroom. Websites which use databases have many advantages. They provide structured, easily accessible and editable content, available to multiple users. Also because most of the information is stored in the database the content can be easily transferred or exported to another web application, new web server or a newer version of the latter.
Create the MySQL database
The phpMyAdmin client
Before you can create your Web application, you must first create the database where your customer information will reside. You will use this database to store the data, display it, and more. Ushering MySQL support into your application requires a few steps. First, you have to create a database as well as the data to go into it, which is where the phpMyAdmin client comes in.
The phpMyAdmin client provides a Web interface (see Figure 1) through which you can manage every aspect of a MySQL database, including managing users, creating databases, adding tables, inserting data, and creating relationships. SQL controls virtually every aspect of the MySQL database.
Figure 1. The phpMyAdmin Web interface
Create the MySQL database
When you have loaded and logged in to phpMyAdmin, perform the following steps to create your database:
The design window appears in which you can configure the three fields in your table. Each field has several options across a row. In this table, you need to create the following fields:
Fill out the fields
Filling out these fields in phpMyAdmin is simple. Simply add the following information, starting with the top row:
Click Save to create your table (see Figure 2).
Figure 2. Create your MySQL table
View the SQL output
An important point to note about phpMyAdmin is that whenever you perform any interactions in the interface, the SQL that was executed to perform the action is displayed to you. This behavior is a fantastic method of learning the nuts and bolts of SQL, so always make a point of observing this output to see what SQL command was used to perform your request. In the case of the table you just created, you get the following SQL:
Now you have to add some data to the table you've created. To do
so, click the Insert tab. The phpMyAdmin interface displays two
forms in which you can add two records (see Figure 3). You don't
actually need to add two records, but having two forms is handy
when you need to add a lot of data. Fill in the
forename and surname fields, and
remember not to add anything to the id field; the
auto_increment option ensures that this field is filled for you.
Add several records to make your database appear full of
customers.Add data to the table
Figure 3. Insert records in the database
table
When you have added the records, click the Browse tab to see the contents of your table, which looks similar to Figure 4.
Figure 4. Browse database records
Access the database through PHP
Connect to MySQL in PHP
With a table created, you're set to roll up your collaborative sleeves and get MySQL hooked into PHP. The first step in performing this process is to make a connection to the MySQL server. When you have made the connection, you're ready to interact with the server.
To begin, create four following variables to contain the details about where the database is and how to connect to it. These variables are db_host, db_username, db_password, and db_database. Note that variables in PHP begin with a dollar sign ($):
Perform the connection These four variables contain important
information about your database connection. The first variable,
$db_host, indicates where the MySQL server is located. (This
location is probably localhost, unless you are running the server
on a separate networked machine.) The $db_username and $db_password
variables contain the authentication details for the connection (in
this case, a user called bob with sum65for! for a
password). Finally, you need to indicate which database on the
MySQL server you want to deal with; $db_database specifies this
database as the customers database.
Remember that at this point, you have not actually connected to the database; you have merely created some variables with the relevant information. To connect to the database, run the following two lines of code:
Perform a queryThe first line actually creates the connection. It
uses the mysql_connect function to pass the host, username, and
password information from the variables to the server. The result
of this connection is stored in the $db variable. In the second
line of code, you then use the mysql_select_db function to indicate
which database on the server you want to use. To do this, pass the
$db_database variable, which contains your chosen database, and
indicate the connection that you want to choose that database from
($db). When you have entered these two lines, you should have a
successful connection.
With a successful connection created, the next step is actually to ask the database for some information so that you can use it in a useful way. In this project, you want to pull the customer information from the database and display it on the screen.
The first step in performing a query is to create the SQL. Underneath the database connection code that you just wrote, add the following line:
In this line, you select all values from the customers table. You can read this command from left to right as such: Select (SELECT) all values (*) from (FROM) the customers table (customers) and then end the query (;). Again, at this point in the script, the query has not actually been executed: You have only put the SQL query into a variable. To actually send the query to the database, use the following command:
In this command, you use the mysql_query function to send the $sql
variable to the server. The result of this query (a collection of
information containing the results from your query) is then made
available in the $result variable. The actual data that is stored
in the $result variable is called a Record Set, and it
provides a container full of information with your results
Pull customers out of the database
So, how does all this array theory relate to getting the customer information out of the database? You use an array to store the details from each row, and store the data in a series of key-value pairs. This way, if you want to get the contents of the forename field, you look up the forename key in the array.
To iterate through each row in the record set, use the following example:
Hope the answer is helpful
.
what is the meaning of LAMP and why do we need it in order to make...
1.what is the meaning of job order costing? 2. why is job order costing important for managerial accounting? 3.how do manufacturing companies use job order and process costing systems?
on a make to order, do we need to prepare forecast if the customers cycle time is shorter than your replenishment cycle.
Why we need estate planning and what age we need to do it?
Explain why we need carbohydrates, meaning why are carbohydrates useful. Give 5 examples why carbohydrates are useful in the body and 5 reasons why carbohydrates are useful in foods.
Why do we need DFT in addition to DTFT? What is the difference between DTFT and DFT? The frequency-domain sampling is equivalent to the time-domain ( What is the minimal condition of digital samples of your signal in order to use FI
Why do we need to have innate reflexes at all? Why do we need involuntary reflexes? In other words, wouldn't we be better off being able to control everything that our body does?
why is trust an action item? How do we become trusteorthy? what actions do we need to take to be trusted in an organization?
do we need an Examination of Inpatient Suicide-Screening Procedures? why or why not? What would be the benefit?
1.Why do we use to 37C bath? 2. What happens if the temperature is too high? 3. For each macromolecule, why do we use on tube with and enzyme and one without? 4.Why do we use on tube with just an enzyme and no substrate? 5. Why may pancreatic lipase not have much effect on digesting milk fat? What else do we need to make the digestion of fats more efficient?
1. How do the terms hypothesis and theory differ in meaning and application? 2. Why do you think physical scientists, such as those working in the fields of physics, chemistry, astronomy, etc., might say that research in the social sciences is unscientific? 3. What materials can a researcher provide others with in order to help them replicate a study? 4. How can applied research help you understand an issue your university or community is currently facing? 5. Identify three ways in which a study might...