การผลิตสื่อดิจิทัล (DIGITAL MEDIA )
สื่อดิจิทัลคืออะไร? DIGITAL REVOLUTION
พรบ.ลิขสิทธิ์และการนำไปใช้เพื่อการศึกษา
ขั้นตอนการผลิตสื่อดิจิทัล ตัวอย่างสื่อชนิดต่างๆ
การผลิตสื่อดิจิทัล (DIGITAL MEDIA )
สื่อดิจิทัลคืออะไร? DIGITAL REVOLUTION
พรบ.ลิขสิทธิ์และการนำไปใช้เพื่อการศึกษา
ขั้นตอนการผลิตสื่อดิจิทัล ตัวอย่างสื่อชนิดต่างๆ
Underscores is a starter theme that can help build the next great WordPress theme without needing PHP or programming knowledge. Foundation 5 is a front-end framework that uses a mobile-first and responsive grid approach. It has new features like fast click, off canvas, GPU acceleration and interchange. Foundation 5 emphasizes building interfaces for mobile screens first before larger displays using a bottom-up approach.
This document provides an overview and examples of Bootstrap, an open-source front-end framework for building responsive mobile-first websites and web apps. It discusses what Bootstrap is, the pre-built HTML and CSS components it contains, how to use its grid system including different screen sizes, and provides examples of websites built with Bootstrap. The speaker is Woratana Ngarmtrakulchol, a front-end developer and founder of Designil.com who is interested in topics like WordPress, front-end development, and web design.
This document discusses connecting a PHP application to a MySQL database. It shows how to connect to the database, execute SQL queries, and retrieve and display the results. Code examples are provided to connect to the database, run SELECT queries, fetch the results into arrays, and loop through the arrays to display the data. Functions are demonstrated to encapsulate the database connection and query execution code for reuse. Finally, examples show how to generate HTML tables and dropdown lists to display the database data.
14. การเขียนโปรแกรมบนเว็บด้วย PHP 14
บทที่ 2 ปูพนฐานภาษา HTML
ื้
ภาษาเอชทีเอ็มแอล (HTML) ย่อมาจาก Hyper Text Markup Language ซึ่งเป็ นภาษาที่
พัฒนามาตั้งแต่ช่วงปลายปี 1986 โดยทีมงานจากห้องปฏิบติการทางจุลภาคฟิ สิ กส์แห่งยุโรป
ั
(European Particle Physics Labs) หรื อที่รู้จกกันในนาม CERN (Conseil European la
ั
Recherche Nucleaire) ประเทศสวิตเซอร์แลนด์ โดยมีการพัฒนานําเสนอข้อมูลในระบบ
WWW (World Wide Web) ซึ่งพัฒนาภาษาที่ใช้สนับสนุนการเผยแพร่ เอกสารของนักวิจย ั
หรื อเอกสารเว็บ (Web Document) คือ ภาษา HTML (Hyper Text Markup Language)
ภาษา html จึงเป็ นภาษาที่ใช้ในการเขียนเว็บเพจ (Web Page) ซึ่งเป็ นไฟล์ที่เขียนขึ้น
เป็ นลักษณะที่มีขอความ มีนามสกุล (Extention) เป็ น .html หรื อ .htm และเว็บเพจนี้จะแสดง
้
ั
ผลได้กบเว็บเบราเซอร์ (Web Browser) หรื อโปรแกรมสําหรับเปิ ดดูเว็บเพจ เช่น Internet
Explorer, Mozilla Firefox หรื อ Opera เป็ นต้น
สําหรับในส่วน Server นั้นไฟล์แรกของเว็บไซต์เราจําเป็ นจะต้องตั้งชื่อให้เป็ นหลัก
สากล เนื่องจาก Server ทุกตัวค่าเริ่ มต้นที่มนจะรันไฟล์แรกคือไฟล์ท่ีมีช่ือว่า index หรื อ
ั
็ ่ ั
default เท่านั้น หากนอกเหนือจากนี้กข้ ึนอยูกบการตั้งค่าที่ตว Server ว่าต้องการให้รันไฟล์ช่ือ
ั
อะไรบ้างเป็ นไฟล์แรก
1. รู ปแบบของภาษา HTML
ภาษา HTML ประกอบไปด้วย Text หรื อข้อความธรรมดา และ Tag หรื อคําสังที่ใช้ใน
่
่
การกําหนดรู ปแบบ Text โดย Tag จะอยูในเครื่ องหมาย <>
This is a <b>bold</b> word.
This is a bold word. คือ Text
<b></b> คือ Tag
This is a <b>bold</b> word.
ผลลัพธ์
This is a bold word.
www.thicakephp.net มานพ กองอุ่น
15. การเขียนโปรแกรมบนเว็บด้วย PHP 15
2. กฎการใช้ HTML
• Tag ต้องอยูในเครื่ องหมาย < > เท่านั้น
่
• Tag พิมพ์ดวยอักษรตัวเล็กตัวใหญ่กให้ความหมายเดียวกัน เช่น <body>
้ ็
กับ <BODY>
• Tag ส่วนใหญ่จะมี Tag เปิ ดและ Tag ปิ ด เช่น <body>…</body>
• บาง Tag ไม่มี Tag ปิ ด เช่น <br>
• จะพิมพ์ Tag และ Text ติดกัน หรื อเคาะช่องว่าง หรื อแยกบรรทัดกันก็ได้
• Tag ส่วนมากจะมี Attribute หรื อส่วนขยายในการกําหนดคุณสมบัติ
ั
ให้กบ Tag เช่น <body bgcolor= “red” เป็ นต้น
่
o อยูภายในเครื่ องหมาย < > ในส่วนของ Tag เปิ ดเท่านั้น
o Tag แต่ละ Tag จะมี Attribute แตกต่างกันไป
o ใช้ช่องว่างคันระหว่าง Attribute
่
เช่น Attribute ของ Tag ที่ใช้ในการกําหนดรู ปแบบตัวอักษร
<font size= “size”>text</font>
<font size= “3”>Hello</font>
เป็ นการกําหนดให้ขอความ Hello มีขนาด 3
้
www.thicakephp.net มานพ กองอุ่น
16. การเขียนโปรแกรมบนเว็บด้วย PHP 16
3. โครงสร้ างของ HTML
<HTML>
<HEAD>
ส่ วนหัว ชื่อเรื่อง <TITLE> </TITLE>
ระบุเป็ น
เอกสาร <META NAME= “" CONTENT= “"> อธิบาย
เอกสาร
เว็บเพจ
HTML
</HEAD>
<BODY>
ขอบเขต
เนือหา
้
</BODY>
</HTML>
โครงสร้างของ html นั้นจะเปิ ด Tag ด้วย <html> และปิ ดด้วย </html> ซึ่งภายในจะ
ประกอบด้วยส่วน head และส่วน body
ส่วน Head จะเป็ นส่วนที่ไม่แสดงผลในเบราเซอร์ แต่มีความสําคัญในกรณี ท่ีจะทํา
SEO (Search Engine Optimization) หรื อปรับเว็บให้เหมาะกับเว็บที่เป็ นเครื่ องมือค้นหา
อย่างเช่น www.google.com
<head>…..</head>
การระบุส่วนหัวของเว็บเพจประกอบไปด้วย Tag ดังต่อไปนี้
Tag ความหมาย
<title>…</title> การระบุชื่อเรื่ องของเว็บเพจที่จะแสดงใน
ส่วนของ Title bar ของเบราเซอร์
<META NAME= "name" CONTENT = Name คือ ชื่อหัวข้อที่จะอธิบาย
"content" > Content คือ คําอธิบาย
www.thicakephp.net มานพ กองอุ่น
17. การเขียนโปรแกรมบนเว็บด้วย PHP 17
ส่วน Body เป็ นส่วนที่ใช้ในการแสดงผลข้อมูล หรื อส่วนเนื้อหาข้อมูล ประกอบไป
ด้วยเนื้อหาในเว็บเพจและ Tag สําหรับการแสดงผล
<body>…..</body>
ตัวอย่าง ไฟล์ ex01.html
<html>
<head>
<title>ส่วนที่จะแสดงที่ Title bar</title>
</head>
<body>
This is my first page.
</body>
</html>
ผลลัพธ์
ตัวอย่าง ไฟล์ ex02.html
<HTML>
<HEAD>
<TITLE>ส่วนที่แสดงที่ Title bar</TITLE>
<META name= “description" content= “Everything
you wanted to know about stamps, from prices to
history.">
<META name= “keywords" content= “stamps, stamp
collecting,stamp history, prices,stamps for sale">
</HEAD>
<BODY>
This is my first page.
</BODY>
</HTML>
www.thicakephp.net มานพ กองอุ่น
82. การเขียนโปรแกรมบนเว็บด้วย PHP 82
<?php
$a=45;
echo 'Hello ';
echo 'I'm a man. <br>';
echo 'Woman said "I'm a woman."<br>';
echo 'This is 1 backslash. <br>';
echo 'This is 2 backslash. <br>';
echo 'This is 3 backslash. <br>';
echo 'This is 4 backslash. <br>';
echo 'value of $a is '.$a.'<br>';
ผลลัพธ์
ตัวอย่าง ex44.php
www.thicakephp.net มานพ กองอุ่น
83. การเขียนโปรแกรมบนเว็บด้วย PHP 83
<?php
$a=45;
echo "Hello ";
echo "I'm a man. <br>";
echo "Woman said "I'm a woman."<br>";
echo "This is 1 backslash. <br>";
echo "This is 2 backslash. <br>";
echo "This is 3 backslash. <br>";
echo "This is 4 backslash. <br>";
echo "value of $a is ".$a."<br>";
echo "value of $"."a is ".$a."<br>";
ผลลัพธ์
ตัวอย่าง ex45.php
www.thicakephp.net มานพ กองอุ่น
84. การเขียนโปรแกรมบนเว็บด้วย PHP 84
<?php
$food = 'Somtam';
echo "$food's taste is great.<br>";
echo "He eat some $foods.<br>";
// won't work, 's' is a valid character for varnames
echo "He eat some $food"."s".".<br>"; // works
echo "He eat some ${food}s.<br>"; // works
echo "He eat some {$food}s.<br>"; // works
ผลลัพธ์
www.thicakephp.net มานพ กองอุ่น
114. การเขียนโปรแกรมบนเว็บด้วย PHP 114
6. Function
Function เป็ นการแบ่งโค้ดโปรแกรมออกเป็ นส่วนย่อยๆ เพือทํางานบางอย่าง
่
- โค้ดโปรแกรมเรี ยงต่อกันยาว
- สามารถเรี ยกใช้ Function ซํ้าได้
รู ปแบบการใช้ ประกาศ Function ส่งค่าแบบ passing by value
function function_name([arguments]){
….
}
รู ปแบบการเรี ยกใช้ Function
function_name([arguments]);
function_name คือ ชื่อฟังก์ชน ั
เป็ น ่
Insensitive case ไม่วาจะเป็ นตัวอักษรใหญ่หรื อเล็ก
เป็ นชื่อเดียวกัน เช่น ShowWord, showword, SHOWWORD,
SHowWorD เป็ นฟังก์ชนเดียวกัน
ั
็
arguments คือ ค่าที่มีการส่งให้ฟังก์ชน อาจมีหรื อไม่มีกได้
ั
ตัวอย่าง ex70.php
<?php
myFunction();
//function declaring
function myFunction(){
echo "Hello from myFunction function<br>";
}
//end of function myFunction()
myFunction();
www.thicakephp.net มานพ กองอุ่น
115. การเขียนโปรแกรมบนเว็บด้วย PHP 115
ผลลัพธ์
ตัวอย่าง ex71.php
<?php
myFunction("Manop Kongoon");
//function declaring
function myFunction($name){
echo "Hello ".$name."<br>";
}
//end of function myFunction()
myFunction("Pranee Thongtee");
ผลลัพธ์
รู ปแบบการใช้ ประกาศ Function ส่งค่าแบบ passing by reference
function function_name([&arguments]){
….
}
รู ปแบบการเรี ยกใช้ Function
www.thicakephp.net มานพ กองอุ่น
116. การเขียนโปรแกรมบนเว็บด้วย PHP 116
function_name([&arguments]);
function_name คือ ชื่อฟังก์ชน ั
เป็ น ่
Insensitive case ไม่วาจะเป็ นตัวอักษรใหญ่หรื อเล็ก
เป็ นชื่อเดียวกัน เช่น ShowWord, showword, SHOWWORD,
SHowWorD เป็ นฟังก์ชนเดียวกัน
ั
็
&arguments คือ ค่าที่มีการส่งให้ฟังก์ชนแบบ passing by reference อาจมีหรื อไม่มีกได้
ั
ตัวอย่าง ex72.php
<?php
//passing by value
function Power($number){
echo "The value of $number power of 2 is ".$number*$number.".<br><br>";
$number=$number+1;
}
$a=3;
echo "The value of $"."a is $a.<br><br>";
Power($a);
echo "The value of $"."a is $a.";
?>
ผลลัพธ์
www.thicakephp.net มานพ กองอุ่น
117. การเขียนโปรแกรมบนเว็บด้วย PHP 117
ตัวอย่าง ex73.php
<?php
//passing by value
function Power($number){
echo "The value of $number power of 2 is ".$number*$number.".<br><br>";
$number=$number+1;
}
$a=3;
echo "The value of $"."a is $a.<br><br>";
Power($a);
echo "The value of $"."a is $a.";
?>
ผลลัพธ์
www.thicakephp.net มานพ กองอุ่น
118. การเขียนโปรแกรมบนเว็บด้วย PHP 118
Global Variables
Global Variable คือ ตัวแปรที่ทุกฟังก์ชนในไฟล์เดียวกันรู้จก
ั ั
รู ปแบบการเรี ยกใช้
function function_name([&arguments]){
….
global global_variable_name;
}
หรื อ
function function_name([&arguments]){
….
$GLOBAL[‘global_variable_name_without_$’];
}
่ ้
global_variable_name คือ ชื่อตัวแปรแบบ global ที่มี $ อยูขางหน้าด้วย
่ ้
global_variable_name_without_$ คือ ชื่อตัวแปรแบบ global ที่ไม่มี $ อยูขางหน้า
ตัวอย่าง ex74.php
<?php //NonGlobal variable in function
$a=1;
$b=2;
function Test(){
$c=3;
$d=4;
echo "Inside function : $a , $b , $c and $d .<br><br>";
}
Test();
h "O t id f ti $ $b $ d $d <b >"
www.thicakephp.net มานพ กองอุ่น
119. การเขียนโปรแกรมบนเว็บด้วย PHP 119
ผลลัพธ์
ตัวอย่าง ex75.php
<?php //Global variable in function
$a=1;
$b=2;
function Test(){
$c=3;
$d=4;
global $a;
echo "Inside function : $a , $b , $c and $d .<br><br>";
}
Test();
h "O t id f ti $ $b $ d $d <b >"
ผลลัพธ์
www.thicakephp.net มานพ กองอุ่น
120. การเขียนโปรแกรมบนเว็บด้วย PHP 120
ตัวอย่าง ex76.php
<?php //Global variable in function
$a=1;
$b=2;
function Test(){
$c=3;
$d=4;
echo "Inside function : ".$GLOBALS['a'] .", $b , $c and $d .<br><br>";
}
Test();
h "O t id f ti $ $b $ d $d <b >"
ผลลัพธ์
ตัวอย่าง ex77.php
www.thicakephp.net มานพ กองอุ่น
121. การเขียนโปรแกรมบนเว็บด้วย PHP 121
<?php //Global variable in function
$a=1;
$b=2;
function Test1(){
global $a,$c;
$c=3;
$d=4;
echo "Inside function 1 : $a , $b , $c and $d .<br><br>";
}
function Test2(){
global $a,$c;
echo "Inside function 2 : $a , $b , $c and $d .<br><br>";
}
Test1();
Test2();
ผลลัพธ์
www.thicakephp.net มานพ กองอุ่น
125. การเขียนโปรแกรมบนเว็บด้วย PHP 125
7. Date and Time
การใช้ฟังก์ชนเกี่ยวกับวันที่และเวลามีสองลักษณะดังนี้
่ั
่
- เรี ยกเวลาจากเครื่ อง ไม่วาจากเครื่ องเซอร์ฟเวอร์ (Server) หรื อเครื่ องไคล์เอนต์
(Client)
- กําหนดตัวเลขให้เป็ นเวลา หรื อเรี ยกสั้นๆ ว่า “Make Time”
การใช้งานเมื่อเรี ยกเวลาจากเครื่ องนั้นส่วนมากใช้งานในกรณี ท่ีมีการส่งข้อมูลเข้า
่ ั
ฐานข้อมูล เช่น เวลาของการส่งกระทู้ เวลาของการสังซื้อสิ นค้า เป็ นต้น ทั้งนี้ข้ ึนอยูกบว่าเรา
่
จะเก็บเวลาจากเครื่ องเซอร์ฟเวอร์ หรื อ เครื่ องไคล์เอนต์ เพื่อให้เป็ นแนวเดียวกันควรเก็บเวลา
จากเครื่ องเซอร์ฟเวอร์ เพราะหากเครื่ องไคล์เอนต์ต้ งเวลาผิด เวลาที่ส่งข้อมูลเข้าเครื่ อง
ั
็
เซอร์ฟเวอร์กจะผิดด้วย บางครั้งเรารู้วนเดือนปี และเวลาที่แน่นอนแล้ว แต่เราไม่สามารถเอา
ั
่
ข้อมูลเหล่านั้นไปแปลงเพื่อให้อยูในรู ปของวันที่และเวลา โดยปกติจะใช้ฟังก์ชน mktime()
่ั
ในการสร้างรู ปแบบของวันที่และเวลา
ตารางรู ปแบบของเวลา
format Description Example returned
character values
Day --- ---
d Day of the month, 2 digits with leading 01 to 31
zeros
D A textual representation of a day, three Mon through Sun
letters
j Day of the month without leading zeros 1 to 31
l A full textual representation of the day Sunday through
(lowercase of the week Saturday
'L')
N ISO-8601 numeric representation of 1 (for Monday) through
the day of the week (added in PHP 7 (for Sunday)
5.1.0)
www.thicakephp.net มานพ กองอุ่น
126. การเขียนโปรแกรมบนเว็บด้วย PHP 126
S English ordinal suffix for the day of the st, nd, rd or th. Works
month, 2 characters well with j
w Numeric representation of the day of 0 (for Sunday) through
the week 6 (for Saturday)
z The day of the year (starting from 0) 0 through 365
Week --- ---
W ISO-8601 week number of year, weeks Example: 42 (the 42nd
starting on Monday (added in PHP week in the year)
4.1.0)
Month --- ---
F A full textual representation of a January through
month, such as January or March December
m Numeric representation of a month, 01 through 12
with leading zeros
M A short textual representation of a Jan through Dec
month, three letters
n Numeric representation of a month, 1 through 12
without leading zeros
t Number of days in the given month 28 through 31
Year --- ---
L Whether it's a leap year 1 if it is a leap year, 0
otherwise.
o ISO-8601 year number. This has the Examples: 1999 or
same value as Y, except that if the ISO 2003
week number (W) belongs to the
previous or next year, that year is used
instead. (added in PHP 5.1.0)
Y A full numeric representation of a year, Examples: 1999 or
4 digits 2003
y A two digit representation of a year Examples: 99 or 03
www.thicakephp.net มานพ กองอุ่น
127. การเขียนโปรแกรมบนเว็บด้วย PHP 127
Time --- ---
a Lowercase Ante meridiem and Post am or pm
meridiem
A Uppercase Ante meridiem and Post AM or PM
meridiem
B Swatch Internet time 000 through 999
g 12-hour format of an hour without 1 through 12
leading zeros
G 24-hour format of an hour without 0 through 23
leading zeros
h 12-hour format of an hour with leading 01 through 12
zeros
H 24-hour format of an hour with leading 00 through 23
zeros
i Minutes with leading zeros 00 to 59
s Seconds, with leading zeros 00 through 59
Timezone --- ---
e Timezone identifier (added in PHP Examples: UTC, GMT,
5.1.0) Atlantic/Azores
I (capital i) Whether or not the date is in daylight 1 if Daylight Saving
saving time Time, 0 otherwise.
O Difference to Greenwich time (GMT) Example: +0200
in hours
P Difference to Greenwich time (GMT) Example: +02:00
with colon between hours and minutes
(added in PHP 5.1.3)
T Timezone setting of this machine Examples: EST, MDT
...
Z Timezone offset in seconds. The offset -43200 through 43200
www.thicakephp.net มานพ กองอุ่น
128. การเขียนโปรแกรมบนเว็บด้วย PHP 128
for timezones west of UTC is always
negative, and for those east of UTC is
always positive.
Full --- ---
Date/Time
c ISO 8601 (added in PHP 5) 2004-02-
12T15:19:21+00:00
r RFC 2822 formatted date Example: Thu, 21 Dec
2000 16:01:07 +0200
U Seconds since the Unix Epoch (January See also time()
1 1970 00:00:00 GMT)
รู ปแบบการเรี ยกวันที่และเวลา
date(“Format”,time());
Format คือ รู ปแบบของการแสดงผล ดูจากตารางด้านบน
ตัวอย่าง ex80.php
<?php
$currentDateTime=date(“Y-m-d H:i:s”,time());
echo $currentDateTime;
ผลลัพธ์
รู ปแบบการสร้างวันที่และเวลา
mktime(Hour, Minute, Second, Month, Day, Year);
www.thicakephp.net มานพ กองอุ่น