Week 1

Updated on 28 Dec 2018

Introduction

Task Weight Date
Task 1: Programming test 20% Week 5 - tutorial
Task 2: Theory test 20% Week 7 lecture
Task 3: Assignment 20% Problems available in Week 8, due Friday Week 12
Theory exam (2 hours) 40% Exam period

In order to pass this unit, you are required to achieve an aggregated total of 50% or more when all assessment items are tallied

Unit text book

Ullman, Larry. (2007) PHP 6 and MySQL 5 for dynamic websites
Berkeley CA: Peachpit Press.

Explain This

void __fastcall TForm1::ListBox1Exit(TObject *Sender)
{
if(ListBox1->MultiSelect)
  {
  for(int i = 0; i < ListBox1->Items->Count; i++)
    ListBox1->Selected[i] = false;
  }
else 
  SendMessage(ListBox1->Handle, 
              LB_SETCURSEL, 
              -1, 
              0);
}
  • Can you explain what this code does?
  • Do you know what language it is written in?
  • Do you recognize compiler specific syntax?
  • Can you find OS specific constructs?
  • Do you recognize any programming constructs?
  • Why is any of this important?

Types of Programming

  • Client – Server Applications
  • Desktop Applications
  • Internet Applications
  • Embedded Applications

Questions

  • What is an example of each?
  • What are the fundamental differences between each?
  • What characteristics do each share?

What are the advantages and disadvantages of:

  • Desktop Applications and Development
  • Internet Applications and Development

Programming Fundamentals

  • Statements
  • Functions / Methods / Procedures
  • Properties / Attributes
  • Events / Triggers
  • Control Structures
  • Loops
  • Variables
  • Arrays / Pointers

Questions

  • Do you know what these lexical topics are?
  • Has anything been missed?

Internet Fundamentals

HTML => HyperText Markup Language

HTML is used to describe the presentation and layout of a document. HTML documents can be viewed in a web browser such as Internet Explorer.

HTML defines a set of tags that can be used to ‘mark-up’ a document.

<p>I am very <b>pleased</b> to meet you</p>

<p> begins a paragraph

</p> ends the paragraph

<b> begins a section of bold text

</b> ends a section of bold text

Question:

  • Do you recognize these tags?
  • Do you know how to write a web-page?
  • Is the <b> tag still used in modern HTML?

When a user goes to a web-page, the user’s web-browser requests the page from the web-server. The web-server returns the HTML code which is then displayed in the browser.

Client Side Scripting

Some web-pages will contain Java-Script which allows ‘client side’ programming to occur within the HTML page. Some examples of this include providing events for form elements, or dynamically writing parts of the HTML page based on user or environment input.

An example of this is where you might call a Javascript function to check the time of day, and then modify your webpage greeting accordingly. E.g. Good Evening, Good Morning etc.

Questions:

  • What are form elements?
  • What sort of events are available for form elements?
  • Why would you have an event for a form element?

Server Side Scripting

When a web-server generates the HTML, this is known as Server Side Scripting. This type of scripting is used to create dynamic web-sites.

Below is a list of some Server Side Scripting languages with PHP being the language that we are using in this unit.

  • ASP
  • PHP
  • Cold Fusion
  • JSP

Question:

  • What is a dynamic website?

Comparing Client side and Server side scripting

Client Side Scripting: Some web-pages will contain Java-Script which allows ‘client side’ programming to occur within the HTML page. Some examples of this include providing events for form elements, or dynamically writing parts of the HTML page based on user or environment input.

Server Side Scripting When a web-server generates the HTML, this is known as Server Side Scripting. This type of scripting is used to create dynamic web-sites.

Question

  • What are the differences between Client Side and Server Side?
  • When would you use one over the other?
  • What can you accomplish with one that you can’t with the other?

Introduction to PHP

PHP originally stood for ‘Personal Home Page’. It was created in 1994 by Rasmus Lerdorf to track the visitors to his online resume.

PHP is a server side scripting language that can be used to create HTML pages or be interspersed within them. PHP is also cross platform meaning that it can be used on a variety of Hardware and Operating Systems.

PHP is designed to do something AFTER an event has occurred. For example when a user submits a form or goes to a URL.

How PHP works

When a visitor goes to a web-page written in PHP the web-server reads the PHP code and then processes it according to its scripting directions to generate the HTML code. This HTML code is then sent to the web-browser.

Question:

  • What do you envisage developing with PHP?

Some PHP code

PHP is a very easy language to learn and use. Remember this HTML from a few slides before:

<p>I am very <b>pleased</b> to meet you</p>

If we used PHP to generate this, we could have written the code like this:

echo '<p> I am very <b>pleased</b> to meet you</p>';

echo is a PHP keyword that sends text to the output. This could be a literal text value, a variable or a combination of both.

We could be a little more dynamic with our message by combining literal text with a variable as shown in the example below.

echo "<p>I am very <b>$mood</b> to meet you</p>";

Notice with the previous two examples that we also supplied the HTML; this is necessary if we want to control the structure of the information being displayed on the browser.

Questions:

  • What is $mood ?
  • What does the $ mean?
  • Do you think there is a difference between single quotes and double quotes?

Some HTML History

HTML – HyperText Markup Language was designed for layout and presentation of text. When the internet started to gather steam, two major Internet Browsers emerged. Microsoft Internet Explorer and Netscape Navigator.

During the ‘browser’ wars, each vendor tried to capture market share by introducing their own HTML add-ins. Some add-ins later became part of the HTML standard, with one notable add-on being the form element; which most websites today wouldn’t be able to do without.

Question:

  • What would have been a disadvantage during the ‘browser’ wars?
  • Can you think of any advantages?

Lab Exercises

You will be working through the exercises in chapters 1-3 and parts of chapter 10 of the course text, PHP 6 and MySQL 5 for dynamic websites, by Larry Ullman during the next 4 weeks.

You should aim to complete each chapter during the lab so that the 4th week of lab work can be used for additional study before the programming test the following week.

All of the software that we use in the labs for this unit is Open-Source, so you are encouraged to install the required components on your home PC for additional study.

What you need:

  • Apache WebServer
  • PHP 5
  • MySQL
  • phpMyAdmin
  • A code editor

Questions:

  • Have you heard of any of the programs listed above?
  • What do you think they do?