Page 518 - Computer_Science_F5
P. 518
In this example when you open the (b) HTML page integrating PHP to
HTML file in a web browser, it will display dynamic content.
display the dynamic content fetched
from the database and styled using (c) Optionally, demonstrate the use of
the CSS. This allows you to create a PHP to fetch and display data from
FOR ONLINE READING ONLY
dynamic gallery of farming crops based a local database table. Chapter Eight: Databases and Database Management Systems
on the data stored in this database.
Integrating or connecting PHP with
SQL database
Activity 8.27:
This section connects PHP to an SQL
Creating dynamic content with php database, enabling you to create, read,
update, and delete database records
Aim: through a PHP application.
To demonstrate the integration of
PHP within HTML and CSS to create PHP and SQL can be integrated for web
dynamic web content, including development. When a user requests a
displaying text and current date web page that needs database access,
dynamically retrieved from a server- the PHP script on the server retrieves
side script. the data from the database and generates
the HTML code for the page. Thus,
Materials: Integrating PHP with SQL typically
1. Computer with Internet access involves connecting to a database using
2. PHP development environment PHP code and then executing SQL
(Such as XAMPP, WAMP) queries to retrieve or manipulate data. To
3. Text editor (Such as Visual Studio connect PHP to MySQL, you can use the
Code, Sublime Text) MySQLi extension or PDO (PHP Data
Objects). MySQLi is object-oriented
Instruction: and only works with MySQL databases,
Develop a basic PHP script to showcase while PDO can work with different
“Welcome to the computer science database systems. These methods allow
course!” along with today’s date on a developers to create, read, update, and
web page. Additionally, integrate PHP delete database records.
within HTML and CSS to generate
dynamic content from a local database Case 1: Connecting PHP to MySQL
table with four columns. using MySQLi function
Deliverables: Connecting PHP to SQL systems like
(a) PHP script displaying “Welcome MySQL using the MySQLi extension is
to the computer science course!” a common approach. It involves setting
and the current date. up a connection by providing details
509
Student’s Book Form Five
Computer Science Form 5.indd 509 23/07/2024 12:35

