Week 7. Lecture 2 Functions, Arrays, PHP&MySQL. Function with More than one argument and a return statement For a function to return a value, the return.

Slides:



Advertisements
Similar presentations
» PHP arrays are lists of values stored in key-value pairs. » Uses of arrays: Many built-in PHP environment variables. Database functions use arrays.
Advertisements

MS-Word XP Lesson 7.
Module 2 Navigation.     Homepage Homepage  Navigation pane that holds the Applications and Modules  Click the double down arrow on the right of.
Access Lesson 2 Creating a Database
SMART Tip Sheets Maryland February 2008 IGSR Technical Support: SMART Basic Navigation Menus/Toolbars Navigation Buttons/Table Actions Controls.
ITC 240: Web Application Programming
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
Microsoft Access 2007 Microsoft Access 2007 Introduction to Database Programs.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
INTERNET APPLICATION DEVELOPMENT For More visit:
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
1 Insert, Update and Delete Queries. 2 Return to you Address Book database. Insert a record.
INF1050- Databases In this module you will use Microsoft Access to create digital databases.
Access Lesson 2 Creating a Database
INTERNET APPLICATION DEVELOPMENT For More visit:
1 MySQL and phpMyAdmin. 2 Navigate to and log on (username: pmadmin)
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
PHP meets MySQL.
MySQL. MySQL is a Relational Database Management System (RDBMS) that runs as a server providing multiuser access to a number of databases. A third party.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Westcap CMS Call Management Contact Management Prospect Management.
1 / 23 © 2006, Universal Tax Systems, Inc. All Rights Reserved. Working with Tax Returns Objectives –In this chapter you will learn how to: Get Started.
PHP+MySQL Integration. Connecting to databases One of the most common tasks when working with dynamic webpages is connecting to a database which holds.
Lesson 1: Exploring Access Learning Objectives After studying this lesson, you will be able to: Start Access and identify elements of the application.
CSC 240 (Blum)1 Forms and Importing Data in Access.
Intro to MySQL 1. Open a browser and enter the following address: It should lead to a log in screen. If your name is.
CHAPTER 7 Form & PHP. Introduction All of the following examples in this section will require two web pages. The first page retrieves information posted.
Microsoft Access 2010 Chapter 10 Administering a Database System.
Oracle 8i PL/SQL Collections. Collections A Collection is a group of elements of the same kind There are three types of Collections that you can use in.
Access Forms and Queries. Entering Data in Your Table  You can add data to your table in Datasheet view, by typing in the columns and rows.  This.
 Decide on the information needed, and create column headings. (See picture below.)
) Main Menu: You can access all aspects of the database from this screen 2) Contacts: You can access the “contact database management” side of.
THE WEBMASTERS: SENG + WAVERING.  On account of construction, we will be having class in room 1248 next week.
PHP getting data from a MySQL database. Replacing XML as data source with MySQL Previously we obtained the data about the training session from an XML.
ARMS Advanced Risk Management System User Documentation.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Planning & Creating a Database By Ms. Naira Microsoft Access.
CSC 240 (Blum)1 Introduction to Access CSC 240 (Blum)2 Click on the Access desktop icon or go to Start/All Programs/Microsoft Office/Microsoft Office.
Chapter 3 Automating Your Work. It is frustrating when you have to type the same passage of text repeatedly. For example your name and address. Word includes.
PubMed/How to Search, Display, Download & (module 4.1)
John Ykema, Director of Sales & Marketing. Agenda  Understanding the NEW Tool  Table JOINS & Database Views  Building your first report  Charts and.
A table is a set of data elements (values) that is organized using a model of vertical columns (which are identified by their name) and horizontal rows.
Pasewark & Pasewark 1 Access Lesson 2 Creating a Database Microsoft Office 2007: Introductory.
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
PART 2 INTRODUCTION TO DYNAMIC WEB CONTENT AND PHP.
>> PHP: MySQL & CRUD. R ecall Database Tables Records is composed of Operations (CRUD) Create Retrieve Update Delete DBMS Access Control MySQL phpMyAdmin.
Welcome to the PJWood tutorial. For starters, let’s do a simple search of the database. We will extract treatment overview data in the Moab field office.
CS 174: Web Programming November 2 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
 An array stores multiple values in one single variable.  Example: Output: I like Honda Civic, BMW and Toyota.
Form Data (part 2) MIS 3502, Fall 2015 Brad N Greenwood, PhD Department of MIS Fox School of Business Temple University 11/10/2015 Slide 1.
Access Queries and Forms. Adding a New Field  To insert a field after you have saved your table, open Access, and open the table  It is easier to add.
Setting up a Development Environment. What you need Webserver (Apache) Database (MySQL) PHP All in Uniserver (google “uniserver”) Download the windows.
1.Switch on the computer and wait for loading. 2.Select the Windows 7 OS at the end of the list. 3.Click on the link ‘Administrator’ 4.Enter the administrator.
MySQL and PHPMyAdmin 1. Make sure your MySQL service is running. If using XAMPP, open the control panel. If the button for MySQL says Start, click it.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Introduction to Web programming
Web Design and Development
Web Design and Development
Web Design and Development
Database application MySQL Database and PhpMyAdmin
MySQL and PHPMyAdmin.
Introduction to Web programming
MySQL and PHPMyAdmin 1.
Color Box Button - Gray Type : object Type : object Type : object
Executive Reports, Instructions and Documentation
Presentation transcript:

Week 7. Lecture 2 Functions, Arrays, PHP&MySQL

Function with More than one argument and a return statement For a function to return a value, the return statement is used. Here is an example for a function that takes two arguments <?php function product($x, $y){ $result = $x * $y; return $result; } echo product(5,10).” ”; echo product(2,3); ?>

Arrays The array() function is used to create an array in php. Array is used when we want to store more than one value in a variable. There are three types of arrays. Indexed Associative Multi-dimensional

INDEXED ARRAY An array can either be index manually or automatically. Array indexing automatically starts numbering at zero. Example: supposing we want to have an array of colors. <?php $colors= array (“red”, “green”, “orange”, “blue”, “yellow”); Echo “the fifth element in the array is ”.$color[4].” ”; ?> The above array is indexed automatically. So yellow is the fifth item and is at index position 4 because numbering starts at 0.

The below shows how to manually index an array. <?php $colors = array(); $colors[0] = “red”; $colors[1] = “green”; $colors[2] = “orange”; $colors[3] = “blue”; $colors[4] = “yellow”; echo “the first element in the array is ”.$color[0].“ ”; ?>

The count() function The count() function is used to return the number of element in an array. <?php $colors= array (“red”, “green”, “orange”, “blue”, “yellow”); echo count($colors); ?> To print out all the values in an array, we could use loops. Like we did in previous lectures, we used the foreach loop, we could also use the count() function with the for loop like this

<?php $colors= array (“red”, “green”, “orange”, “blue”, “yellow”); $elements = count($colors); // let $i be the array index for ($i = 0; $i<$elements; $i++){ echo $colors[$i].” ”; } ?>

Associative arrays This is the type of array that uses named keys assigned to them. <?php $id = array(“admin”=> “001”, “user” => “002”); echo “the admin employee id is ”.$id[‘admin’].” ”; ?>

PHP and MySql To create database with MySQL, we are going to be using phpmyadmin. So launch wamp server and instead of going to the www directory, click on phpmyadmin or you could just open your browser and type for the url. Data in MySQL is stored in tables. A database is a means of storing Information. After opening phpmyadmin, click on the database tab. In the text box of create database, type a name for your database and click the create button.

Then, click on the newly created database to create a table. Enter the name for the table and the number of columns the table will hold. After entering a name for your column, the next thing you do is to set the type of data each column will hold by clicking on the type drop-down menu. The null check box is used to set whether a field can be left blank by the user or not. After entering all the fields, click on save. Next is to start inserting records by clicking on the insert tab. All record should be entered in the textbox of the value column. When all records have been entered, click on the go button to create the rows.