PHP & MySQL

Chapter 12: Getting Data from a Database

NOTE: You must update the cms/includes/database-connection.php file
with information about your database for these examples to work.

The code for this chapter is split into two folders:

PageTitleFilename
439Sample Site Home Page
(to check database-connection.php)
index.php
444Getting a Single Row of Dataquery-one-row.php
445Checking if the Database Returned Datachecking-for-data.php
446Getting Multiple Rows of Dataquery-multiple-rows.php
447Loops to Show One Row of Data at a Timequery-multiple-rows-while-loop.php
449Using Placeholders in SQL Queriesprepared-statement.php
451Using bindValue() to Replace Placeholders bind-value.php
453Using Query Strings to Show the Right Pagequery-strings-and-prepared-statements.php?id=1
455Formatting Data in HTML Pagesformatting-data-in-html.php
458Custom PDO Function - No Parameterspdo-function-no-parameters.php
459Custom PDO Function - With Parameterspdo-function-with-parameters.php?id=1
465Home Pageindex.php
467Category Pagecategory.php?id=1
469Article Pagearticle.php?id=1
471Member Profile Pagemember.php?id=1
475Search Pagesearch.php?term=design
479Member List Using Objectsfetching-data-as-objects.php
481Member List Using Class to Create Objectsfetching-data-into-class.php