Tuesday, 3 May 2016

WEEK10_Class of MySQL and Database Integration

Database is integrated collection of data

DBMS is provides machanism for storing and organizing data and also allow user to access and store data without addressing internal representation of database.

Relational database
-- consists of data corresponding to one another 
-- most popular database system in use
-- use SQL to create queries


SQL Data Manipulation Language (DML)
- SELECT
- UPDATE
- DELETE
- INSERT INTO

SQL Data Definition Language (DML)
- CREATE TABLE
- ALTER TABLE
- DROP TABLE
- CREATE INDEX
- DROP INDEX

Introduction to Database Interface (DBI)
  • database part of distributed application
  • driver - helps program access databases
  • interface
  • database interface
This link can help you more undestanding about (selected data, insert data, delete selected data, update selected data)

Advantages of using database to store web data:
  1. faster access
  2. better concurrent access
  3. easier changes to data and script
  4. increased security
There are four step to access MySQL via PHP:
  1. STEP 1: Make a connection to the MySQL database server
  2. STEP 2: Select the database within MySQL that you want to work with
  3. STEP 3: Issue an SQL statement / create the query
  4. STEP 4: Iterate through the SQL Result Set

WEEK8_Lab Session

Today, we are doing some exercise on past year question.

this is past year question:
http://www.psb1.uum.edu.my/ks/Kolej%20Sastera%20dan%20Sains/UUMCASsem1_1516/PUSAT%20TEKNOLOGI%20MEDIA%20%26%20KOMUNIKASI/STIV3013_1_2015_2016.pdf

We discussed about Section B (75%), our lecturer said if you done and know how to do this part, u can pass in the exam..Well, i trust because it is difficult....

ANSWER:

//retrieved information from the form
    
    $name = $_POST["name"];
    $matric = $_POST["matric"];
    $stiv1023_mark = $_POST["stiv1023_mark"];
    $stiv2023_mark = $_POST["stiv2023_mark"];
    $stiv3013_mark = $_POST["stiv3013_mark"];
    $vkhb2031_mark = $_POST["vkhb2031_mark"];

//calculate grade for each course by calling calculateGred() function
   
    $stiv1023_gred = calculateGred($stiv1023_mark);
    $stiv2023_gred = calculateGred($stiv2023_mark);
    $stiv3013_gred = calculateGred($stiv3013_mark);
    $vkhb2031_gred = calculateGred($vkhb2031_mark);

//calculate point for each course by calling calculatePoint() function
   
    $stiv1023_point = calculatePoint($stiv1023_gred);
    $stiv2023_point = calculatePoint($stiv2023_gred);
    $stiv3013_point = calculatePoint($stiv3013_gred);
    $vkhb2031_point = calculatePoint($vkhb2031_gred);

//calculate TotalPoint based on point for each course and credit
    
    $TotalPoint = $stiv1023_point * 3 + $stiv2023_point * 3 + $stiv3013_point * 3 +    $vkhb2031_point * 1;

//calculate GPA based on TotalPoint and total credit
   
    $GPA = $TotalPoint / 10;

//calculate final result by calling calculateResult() function
   
    $result = calculateResult($GPA);
   
//function to calculate the grade based on mark
   
    function calculateGred($mark)
    {
        if ($mark >= 90)
            $gred = "A";
           
        else if ($mark >= 80)
            $gred = "B";
           
        else if ($mark >= 70)
            $gred = "C";
           
        else if ($mark >= 60)
            $gred = "D";
           
        else if ($mark >= 50)
            $gred = "E";
           
        else
            $gred = "F";
       
        return $gred;
    }

//function to calculate the point based on grade
   
    function calculatePoint($gred)
    {
        if ($gred == "A")
            $point = 4.00;
           
        else if ($gred == "B")
            $point = 3.50;
           
        else if ($gred == "C")
            $point = 3.00;
           
        else if ($gred == "D")
            $point = 2.50;
           
        else if ($gred == "E")
            $point = 2.00;
           
        else
            $point = 1.00;
           
        return $point;
    }
   
//function to calculate the result based on GPA
   
    function calculateResult($GPA)
    {
        if ($GPA >= 3.00)
            $result = "Pass with distinction";
       
        else if ($GPA >= 2.00)
            $result = "Pass";
           
        else
            $result = "Fail";
           
        return $result;
    }

Sunday, 24 April 2016

WEEK8_Class of PHP & Form

In this class, we are learning about new things - PHP and FORM.

OK, what is PHP. PHP is really good at handling data submitted to the server in HTML forms. HTML forms allow users to enter data into a web page.

Simple Form Precessing

<form METHOD= "GET"
           ACTION=  "process.php">


2 main attribute in a form :

1*METHOD
   Get/post

2*ACTION
    -used to specify the target which is where the data is to be transmitted.
    -the target is a file that contains code for processing.


$_GET variable

  • an array of variable names and value sent by the HTTP GET method
$_POST variable
  • an array of viarable names and values sent by the HTTP POST method.
$_REQUEST variable
  • contain the content of both $_GET, $_POST, $_COOKIES.
  • used to get the result from form data sent with both the GET and POST methods.


Example of Getting form value: 


Example of Displaying submitted values: 


Authentication using USERNAME & PASSWORD
  • allowing a user to access private information or preventing them from doing so.

Example of aunthenification



Managing Session
  • duration for which a user is connected to a site.
  • also as a block of information that stores variable and values.
  • feature: i. consist of an identification string.
i. to start a session and to track session variable across user session

session_start();

ii. to register a session

session_register (variable);

iii. to destroy a session

session_destroy();





WEEK 7_In Class

Today, our lecturer give us do some the exercise in class.

How to calculate the BMI using php code:

 

BMI Categories

Underweight = <18.5
Normal weight = 18.5-24.9
Overweight = 25-29.9
Obesity = BMI of 30 or greater

if ($BMI>= 30)
echo "obes";
elseif ($BMI>= 25)
echo "overweight";
elseif ($BMI>= 18.5)
echo "normal";
else
echo "underweight";





Picture when lecturer was explaining how to do question above XDXD 

WEEK 6_Lab Session - Doing some Exercise

These are the lab question that given by our lecturer.

Question 1.
 <?php
   $name = "Syamsul Bahrin Zaibon";
?>

<html>
      <head>
<title>Intro to PHP</title>
</head>
<body>
    <h1>
      <!--Basic PHP Code.
      to print variable name's value --!>
      Dear <?php print ($name);?> Welcome to PHP
    </h1>
</body>
</html>

output: 


Question 2,
<?php
      $height = 150;
      $width = 30;
?>

<html><head><title>Using Variables and Operators</title></head>
<body>
           <h2> The output of the code: </h2><br>
           <?php
                $luas = $height * $width;
                print ("Luas segi empat dengan panjang $height dan lebar $width ialah $luas");
           ?>
</body>
</html>

output: 



To modify above code so that can compute and display net salary based on information give.
<?php
      $salary = 2100;
      $allowances = 1000;
 $socso = 210;
?>

<html><head><title>Using Variables and Operators</title></head>
<body>
           <h2> The output of the net salary: </h2><br>
           <?php
                $net = $salary + $allowances - $socso;
                print ("Net Salary is $net");
           ?>
</body>
</html>

output: 

Question3.
<html>

<head><title>Table</title></head>

<body>
      <h1>The output of the code: </h1><br>

<TABLE BORDER = "1">
<?php
            for($row = 1; $row<=3; $row++)
            {
print ("<TR>");//create row
for ($column =1; $column <=2; $column++)
{
         print("<TD>"); //create column
         print("Baris $row, Lajur $column");
              print("</TD>");
             }
             print ("</TR>");
            }
          ?>
</TABLE>

</body>
</html>

output: 


Question 4.

Correct the code that have error in code.

a).
<html>
<head><title>Syntax</title></head>
<body>
      <h1> The output of the code: </h1><br />
   <?php
         for ($a=1;$a<10;$a++)
         {
      echo $a,"\n";
         }
         ?>
</body>
</html>


b).
<html>
<head><title>Syntax</title></head>
<body>
       <h1> The output of the code: </h1><br />
  Welcome <?php echo $_POST["name"];?><br>
       You are <?php echo $_POST ["age"];?>years old
</body>
</html>


















Monday, 28 March 2016

WEEK6_Introduction PHP

Today we learned about PHP. Throughout this class, i feel PHP is interesting and fun. This is because when you miss something, it cannot be run in system.

What is PHP?
PHP is an open source and eventually the name changed to PHP Hypertext Pre-procesor.

Advantage of PHP:
a. easy to use
b. open source
c. multiple platform
d. language support for database


  • must saved with a php extension
  • must be terminated with a semicolon ;
  • not generally case-sensitive
  • character to indicate Comments : - // or # : single line
  •                                                       - /* here is an introduction to server side script code inside a                                                                    multi-line comment */ : multi-line comment
PHP Syntax
1. PHP comment
2. Output / Display statement


Variables and Data Type
- variable contain a piece of data
- all variable in PHP begin with a $
- variable names are case sensitive

Operator 



Conditional Statement and Loops


Arrays
- array is a variable only contain a multiple value under a single variable name
- Example: To store information about a car in an array, we could use the following line; 

$CarInfo = array ("Avanza", "2004", 34500);
// an array could contain different type of variables

OR

$CarInfo = array();
$CarInfo [0] = "Innova";
$CarInfo [1] = "2002";
$CarInfo [2] = 34500;


Thursday, 24 March 2016

WEEK5_Installation XAMPP

In this lab session, we are asked to bring laptop to install XAMPP in our laptop.

download free : https://www.apachefriends.org/index.html

XAMPP is a free and open source cross-platform web server package, consisting mainly of the
1. Apache
2. MySQL
3. PHP
4. Perl programming language

We should store our file that need to connect to Xampp in htdocs file

Example: the folder named "lab_HTML_BASIC" is save in htdocs folder, open the XAMPP to start, then u can start to launch the website http://localhost/lab_HTML_BASIC/main.html.



Interface of XAMPP

Monday, 21 March 2016

WEEK5_CSS & JavaScript

3 way of inserting a style sheet:

1. External style sheet


2. Internal style sheet


3. Inline style



CSS Selectors =to apply a declared style

selectors type have:

a. Element selectors
b. Class Selectors

.legs { font-weight: bold; background: pink;}

c. ID Selectors

#snout { border: solid red;}

d. Pseudo Selectors

-specific to hyperlink



JAVA Script

where to put JavaScript?
* between the HTML document's head tags
* within the HTML document's body
*in an external file 








Thursday, 17 March 2016

WEEK4_QUIZ WWW

Today our class held quiz for slide 1-4, there  are 30 question in quiz.

1. What is the correct HTML for adding a background color?

a. <bgcolor="yellow"> Incorrect

b. <body bgcolor="yellow">

c. <background>yellow</background> 


2. What is the correct HTML for making a checkbox?
a. <checkbox>

b. <input type="checkbox"> Correct

c. <check>

d. <input type="check"> 


3.High-level language needs compiler to translate to machine languages
 a. True

b. False 


4.Choose the correct HTML element for the largest heading:
a. <h6>

b. <heading>

c. <h1>


5.  What is the correct HTML for inserting a background image?
a. <background img="background.gif">

b. <body background="background.gif">

c. <body bg="background.gif">


6.  Choose the correct HTML element to define emphasized text
a. <strong>

b. <italic>

c. <em> 


7.Which tag contains ALL of the website's visible content?
a. <title>

b. <body> 

c. <html>

d. <head> 


8.HTML comments start with <!-- and end with -->
a. True 

b. False 


9.Example of High Level Language
a. COBOL

b. C++

c. FORTRAN

d. BASIC


10.What is an HTML element?
 a. Everything which is visible when viewing the site

b. Everything inside the head tag

c. Start tag and an end tag, with content in between

d. Content inside body tag 


11. How can you open a link in a new tab/browser window?
a. <a href="url" target="new">

b. <a href="url" new>

c. <a href="url" target="_blank"> 

Tuesday, 15 March 2016

WEEK4_Class of Client Server & Internet Application

In today class, we are learn about the concept of Client server (Client Side Script Server Side Script) & Internet Application.

Client and Server - cooperate to deliver network services

Client is to initiates communication and server is to send information's back to client.


Client-Side and Server-Side


Client-Side Scripts
Server-Side Scripts
Are interpreted by the browser
Proceed by the server to generate HTML
Can embedded into HTML documents or contained in separate file
Provide interactive web sites that interface to database or data stores
Proceed at browser

Reduce the number of requests



Internet Application 

Network Application Support
Transport Protocol
Network Communication
File transfer
Eg: TCP/IP, Netbean
Ethernet, telephone
Complete user visible support service
Transmit message into network between network and from segment to another
Computer must be connected



Client Tier vs Middle Tier vs Information Tier





An application consists of three main parts:
1. Form
2. Process
3. Database

Saturday, 12 March 2016

WEEK3_LAB HTML Form

today, our class do the lab exercise to create a form.

Result of question:
at the end, we must come out this Registration form as the picture above.

now is showing the HTML part for doing this form!!!

1. Name (text box)

<h1>Registrstion Form</h1> 
<form action="action_page.php">
<table border="2">
       <tr>
    <td>Name:</td>
        <td><input type="text" value="Yunalis"></td>
      </tr>
**<td> for column
    <tr>for row

2. IC No (text box)

<tr>
       <td>IC No:</td>
       <td><input type="text" name="ic no" value="870910-04-5566"></td>
</tr>

3.Address (text area)

<tr>
       <td>Address:</td>
       <td><textarea name = "message" rows="10" cols="30"></textarea></td>
</tr>

4.Gender (radio button)
<tr>
       <td>Gender:</td>
        <td><input type="radio" name="gender" value"male">Male
               <input type="radio" name="gender" value"female">Female</td>
</tr>

5.Dance Type (checkbox)

<tr>
  <td>Dance Type:</td>
        <td><input type="checkbox" name="dance1" value="Zapin">Zapin
               <input type="checkbox" name="dance2" value="Joket">Joket
               <input type="checkbox" name="dance3" value="Inang">Inang
               <input type="checkbox" name="dance4" value="Lion Dance">Lion Dance</td>
</tr>

6. Competition (select choose 1 only)

<tr>
      <td>Competiton:</td>   
      <td><select name="competition" size=3>
            <option>State Level
            <option>National Level
            <option>Internel Level
            </select>
        </td>
  </tr>

7. Nationality (multiple select)

<tr>
      <td>Nationality:</td>
      <td><select name="nationality">
             <option value="-please select">-please select</option>
             <option value="Malaysian">Malaysian</option>
             <option value="Non-Malaysia">Non-Malaysia</option>
       </select>
       <p></p><br><p></p></td>
  </tr>


8.Password (password box)

<tr>
       <td>Password:</td>
        <td><input type="password" name="psw"></td>
   </tr>

9.Register me & Cancel (submit & reset)

     <input type="submit" value="Register Me">
     <input type="reset" value="Cancel">

Monday, 7 March 2016

WEEK3_Class of HTML Form

Well, what i learning today is create a Form.

Form is divided into 2 which is 1. Action (script)
                                                  2. Method (post or get)


Compare Get and Post!!


What is INPUT? (script is <input type= "text" name)
--Text
--Password
--Radio
--Checkbox

WHY we must use this different input into form?-----this is because user friendly, to avoid client                                                                                              key in wrong data and also consistent data.


i quite confuse with two these type of input~~


Example of Radio button


Example of Checkbox


What is Select?
1. select one only
2.multiple select

Text area normally is used for address, comment and description.

Submit & Reset
<input type = “submit" value= "Go!”>
<input type = “reset" value= "Clear”>


Exercise in class!!!
1. add a drop down lists with name ="cars" to the form. Include the following option = "Volvo", "Ford", "Fiat", and "Audi".

ans:

<p>select your car
<select name = "cars">
          <option value= "volvo">Volvo
          <option value= "ford">Ford
         <option value= "fiat">Fiat
         <option value= "audi">Audi
</select>
</p>

Saturday, 5 March 2016

WEEK2 _Lab Tutorial of Dreamweaver

Well, today i learn many things in my WWW lab session.

Our lecturer give us two task which are 1. create 2 more page (Hobby and Experience)
                                                                2. link the page together

We need to change the color, font, picture. Yup, i think it is troublesome BUT i quite enjoy it when i done my work i feel proud. HAHA


I added the two more column for Hobby and Experience.





The coding when change the picture =

<tr>
    <td colspan="6"><img src="DMAS.jpg" width="1320" height="200" /></td>
  </tr>


The coding when change the color =
<tr>
     <td colspan="6" bgcolor="#000000"><div align="center" class="style1 style1">2016 Copyrights. Designed by David</div></td>
  </tr>

This is the code that i wrote in my Dreamweaver.

By the way, I enjoy it~





Monday, 29 February 2016

WEEK2_Class of HTML

Yes, this is the first time write the blog for my assignment-WWW, so far, i enjoying it XD

After end of the class, i just realize that i misunderstand the meaning of INTERNET and WEB before.

During the class, i explore more and more about WWW - HTML (main language). i know about the basic HTML tags.



This is the link that i found in youtube to write the simple HTML. THIS IS QUITE INTERESTING....
https://www.youtube.com/watch?v=bWPMSSsVdPk

I am excited to explore more about WWW and waiting~~~