Skip to content

Instantly share code, notes, and snippets.

View anaelleltd's full-sized avatar

Anaelle LTD anaelleltd

  • Anaelle LTD
  • Australia
View GitHub Profile
Task:
Use PDO to establish a connection to a MySQL server
Catch an exception with a try-catch statement
Use the exit function
Configure PDO for exception by calling the PDO object’s setAttribute method - p103 of text
Configure character encoding utf8
Set the output to say 'Unable to connect to the database server.' If cannot connect. And include the error message.
Set the output to say 'Database connection established.'
<?php
Task:
Use PDO to establish a connection to a MySQL server
Catch an exception with a try-catch statement
Use the exit function
Configure PDO for exception by calling the PDO object’s setAttribute method - p103 of text
Configure character encoding utf8
Set the output to say 'Unable to connect to the database server.' If cannot connect. And include the error message.
Set the output to say 'Database connection established.'
<!doctype html>
@anaelleltd
anaelleltd / Templates in PHP part4
Created March 17, 2019 11:52
Controller and Master template
Task:
1. Make a simple web site with at least 3 types of pages (you may include a landing page, a gallery page and a contact page).
a. All types shall share a common masthead header, footer and navigation.
2. Make a page controller for each page and set title, heading and other data in variables.
3. Make a master template for every type of page that in turn will include the smaller page parts. (All data can be considered safe
for this exercise, making filtering and escaping unnecessary)
@anaelleltd
anaelleltd / Templates in PHP part3
Created March 17, 2019 11:49
Header Nav Footer
Task:
1. Make a simple web site with at least 3 types of pages (you may include a landing page, a gallery page and a contact page).
a. All types shall share a common masthead header, footer and navigation.
2. Make a page controller for each page and set title, heading and other data in variables.
3. Make a master template for every type of page that in turn will include the smaller page parts. (All data can be considered safe
for this exercise, making filtering and escaping unnecessary)
<header>
<div id="header">
STRAWBERRIES Inc <img src="images/strawberriesinc1.jpg" alt="Strawberries Inc logo"/>
Task:
1. Make a simple web site with at least 3 types of pages (you may include a landing page, a gallery page and a contact page).
a. All types shall share a common masthead header, footer and navigation.
2. Make a page controller for each page and set title, heading and other data in variables.
3. Make a master template for every type of page that in turn will include the smaller page parts. (All data can be considered safe
for this exercise, making filtering and escaping unnecessary)
<main>
<a name="maincontent"></a>
<aside> <div id="aside1">
Task:
1. Make a simple web site with at least 3 types of pages (you may include a landing page, a gallery page and a contact page).
a. All types shall share a common masthead header, footer and navigation.
2. Make a page controller for each page and set title, heading and other data in variables.
3. Make a master template for every type of page that in turn will include the smaller page parts. (All data can be considered safe
for this exercise, making filtering and escaping unnecessary)
<!DOCTYPE HTML>
<html>
<head>
@anaelleltd
anaelleltd / Timetables in PHP v3
Last active March 17, 2019 11:42
Final table design
Task:
Produce a web page that has two Multiplication tables in it Each table is to be produced by one loop and you will need
to demonstrate a FOR loop and a WHILE loop to complete this task, hence, creating two separate tables.
Page Requirements Alternate rows shall be coloured using html attribute names Every cell containing the result of the square
of a number (1x1, 2x2, 3x3 etc) shall also have distinctive background using a html attribute name Create your times table from 1 to12.
(ie: 1x1 ... 12x12) - for both times tables. Please display only the result (i.e: 1, 2, 4, 144) for the FOR loop table and
display the calculation and result (i.e: 1x1=1, 2x2=4, etc) for the WHILE loop table.
I have broken down the completion of this task into 3 different versions.
These versions document the coding process: from table design, to operation through loops, to the final update of the table design.
@anaelleltd
anaelleltd / Timetables in PHP v2
Last active March 17, 2019 11:42
Loops operations
Task:
Produce a web page that has two Multiplication tables in it Each table is to be produced by one loop and you will need
to demonstrate a FOR loop and a WHILE loop to complete this task, hence, creating two separate tables.
Page Requirements Alternate rows shall be coloured using html attribute names Every cell containing the result of the square
of a number (1x1, 2x2, 3x3 etc) shall also have distinctive background using a html attribute name Create your times table from 1 to12.
(ie: 1x1 ... 12x12) - for both times tables. Please display only the result (i.e: 1, 2, 4, 144) for the FOR loop table and
display the calculation and result (i.e: 1x1=1, 2x2=4, etc) for the WHILE loop table.
I have broken down the completion of this task into 3 different versions.
These versions document the coding process: from table design, to operation through loops, to the final update of the table design.
@anaelleltd
anaelleltd / Timetables in PHP v1
Last active March 17, 2019 11:41
Table design
Task:
Produce a web page that has two Multiplication tables in it Each table is to be produced by one loop and you will need
to demonstrate a FOR loop and a WHILE loop to complete this task, hence, creating two separate tables.
Page Requirements Alternate rows shall be coloured using html attribute names Every cell containing the result of the square
of a number (1x1, 2x2, 3x3 etc) shall also have distinctive background using a html attribute name Create your times table from 1 to12.
(ie: 1x1 ... 12x12) - for both times tables. Please display only the result (i.e: 1, 2, 4, 144) for the FOR loop table and
display the calculation and result (i.e: 1x1=1, 2x2=4, etc) for the WHILE loop table.
I have broken down the completion of this task into 3 different versions.
These versions document the coding process: from table design, to operation through loops, to the final update of the table design.