Accessing Your MySQL Database from the Web with PHP | Linux Today

Accessing Your MySQL Database from the Web with PHP

Written By
Web Webster
Web Webster
Nov 26, 2008

“In Chapter 8, “Designing Your Web Database, “we outlined how
web database architectures work. Just to remind you, here are the
steps:

  1. A user’s web browser issues an HTTP request for a particular
    web page. For example, the user might have requested a search for
    all the books written by Michael Morgan at Book-O-Rama, using an
    HTML form. The search results page is called results.php.
  2. The web server receives the request for results.php, retrieves
    the file, and passes it to the PHP engine for processing.
  3. The PHP engine begins parsing the script. Inside the script is
    a command to connect to the database and execute a query (perform
    the search for books). PHP opens a connection to the MySQL server
    and sends on the appropriate query.
  4. The MySQL server receives the database query, processes it, and
    sends the results-a list of books-back to the PHP engine.
  5. The PHP engine finishes running the script. This usually
    involves formatting the query results nicely in HTML. It then
    returns the resulting HTML to the web server. The web server passes
    the HTML back to the browser, where the user can see the list of
    books she requested.

“Now you have an existing MySQL database, so you can write the PHP
code to perform the preceding steps.Begin with the search form. The
code for this plain HTML form is shown in Listing
11.1.”

Complete
Story

Web Webster

Web Webster

Web Webster has more than 20 years of writing and editorial experience in the tech sector. He’s written and edited news, demand generation, user-focused, and thought leadership content for business software solutions, consumer tech, and Linux Today, he edits and writes for a portfolio of tech industry news and analysis websites including webopedia.com, and DatabaseJournal.com.

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.