PHP /
Learn on the job: a project from draft to prototype..Lecture 5, Learn on the job: a project from draft to prototype.. March 19..This week, we are going to continue to learn some language elements, whilst also adding a lot of new material. To facilitate this, we are going to use a real-world scenario. We will be learning about:
This week's code scenario: The Drinks Run.I work in a busy office with 5 other people, and there are a further 5 to 10 people in the offices along the corridor. Throughout the day, any one of the employees will make a drinks run and bellow "who's drinking what?" I have decided that, as we all have immediate access to an intranet with PHP support and an unused office section, to design a drinks run web page, which needs to work thus: 1. Someone decides they are going to make drinks and tells the office. For now, the current method of shouting at the top of their lungs is suitable. 2. Anyone who wants a drink connects to the appropriate web page, chooses from a list of drinks, enters any comments and clicks a button. 3. The runner is then able to see the list of who's chosen what, and goes and makes the drinks without having had to scurry around with a pad and pencil. Before any heavy development begins, the second stage, where the drinks are chosen, needs to be designed. This is important because if the interface isn't good, staff won't want to use it. When they are comfortable using their drinks selection screen, then we can progress to the forwarding of that data on to the person making the drinks. The code.As with the previous lectures, a Attach:l5code.zip set of code example files will be provided. We'll start out simply, putting our drinks in to the system, then progress to allowing them to be chosen, comments added etc. For a larger project we'd sketch things out on paper first, but you'll see how a program of this sort is built up and added to as features are needed. This week is going to include a lot of code, and it is likely that you won't understand it all on a first listen through. Of more importance than comprehending every line of the code is that you have a general overview of what the code is supposed to do, which you can then use to guide you in your own analysis of the files, supplemented with the lecture recording and mailing list or study group support. Assignment for lecture 5.A brief assignment, because I really want you to dive into the example code and really, really try and understand how it does what it does. For this week, just answer the following few questions to the submit-php address. 1. What is wrong with the following line of code? $drinks= "tea coffee water juice carbonated"); 2. In class we used the PHP explode function, which returns an array. What type of variable does the implode function return? 3. Assume a form had been submitted, and the submit button was called "btnOrder". The line of code below, testing for that submission, will never return true. Why is this? if ( isSet ($_get['btnOrder'] ) ){ // code to process the form goes here; } 4. Describe one thing you have found in the example code for this week that interests you, or that you can see to apply to your own ideas. 5. Describe one thing in the example code that you either don't understand, or didn't understand to begin with |