APPENDIX. dbskripsi.sql CREATE DATABASE drop database if exists dbskripsi; create database dbskripsi; use dbskripsi;

Size: px
Start display at page:

Download "APPENDIX. dbskripsi.sql CREATE DATABASE drop database if exists dbskripsi; create database dbskripsi; use dbskripsi;"

Transcription

1 APPENDIX dbskripsi.sql CREATE DATABASE drop database if exists dbskripsi; create database dbskripsi; use dbskripsi; PROCEDURE CREATE TABLES delimiter $$ create procedure spfirsttimerunning() begin drop table if exists tblrelasi; drop table if exists tblpelaku; drop table if exists tblpekerjaan; drop table if exists tblproses; drop table if exists tblminimbaris; drop table if exists tblminimkolom; drop table if exists tbltotalnilaiminim; drop table if exists tbltemphasil; drop table if exists tblsorttemphasil; drop table if exists tblmostpekerjaan; drop table if exists tblhasil; create table tblpelaku ( idpelaku int primary key, namapelaku varchar(100) ); create table tblpekerjaan ( idpekerjaan int primary key, namapekerjaan varchar(100) ); create table tblrelasi ( idpelaku int, idpekerjaan int, tarif int, foreign key (idpelaku) references tblpelaku(idpelaku), foreign key (idpekerjaan) references tblpekerjaan(idpekerjaan) ); A

2 create table tblproses ( kolom1 varchar(100) ); create table tblminimbaris ( nilaiminimbaris int ); create table tblminimkolom ( nilaiminimkolom int ); create table tbltotalnilaiminim ( totalnilaiminim int ); create table tbltemphasil ( namapelaku varchar(100), namapekerjaan varchar(100), tarif int ); create table tblsorttemphasil ( namapelaku varchar(100), namapekerjaan varchar(100), tarif int ); create table tblmostpekerjaan ( namapelaku varchar(100), namapekerjaan varchar(100) ); create table tblhasil ( namapelaku varchar(100), namapekerjaan varchar(100), tarif int ); end; $$ delimiter ; B

3 PROCEDURE GENERATE RANDOM NUMBERS delimiter $$ create procedure spgenerateangka(jmldata int) begin declare i,j int default 1; declare randomx int; declare status varchar(100); declare batasmax int; declare batasmin int; set batasmax = 100; set batasmin = 40; set status = 'false'; set i=1; while i <= jmldata do set j=1; while j <= jmldata do set status = 'false'; while status!='true' do SELECT ROUND(RAND()*batasMax) into randomx; if(randomx < batasmax and randomx > batasmin) then insert into tblrelasi values(j,i,randomx); set status = 'true'; set j=j+1; set i = i+1; end; $$ delimiter ; PROCEDURE INPUT DATA INTO TABLE PROCESSING delimiter $$ create procedure spinputintotable() begin declare i,j,k int default 1; declare tmp int; declare idnama int; declare idkerjaan int; declare idnamarelasi int; declare idkerjaanrelasi int; declare tarifrelasi int; declare nama varchar(100); declare kerjaan varchar(100); C

4 declare angka int; declare jmldata int; declare totaldata int; declare P varchar(100); declare dinamis varchar(100); declare kursorpelaku cursor for select * from tblpelaku; declare kursorkerjaan cursor for select * from tblpekerjaan; declare kursorrelasi cursor for select * from tblrelasi; select count(*) from tblpekerjaan into jmldata; set totaldata = jmldata*jmldata; select '' as '==========Data Asal=========='; open kursorpelaku; while i <= jmldata do fetch kursorpelaku into idnama, nama; insert into tblproses values (nama); set i = i+1; close kursorpelaku; open kursorkerjaan; while j <= jmldata do fetch kursorkerjaan into idkerjaan, kerjaan; table tblproses ',kerjaan,'int'); PREPARE QUERY EXECUTE QUERY; DEALLOCATE PREPARE QUERY; set j = j+1; close kursorkerjaan; set i = 1; set j = 1; open kursorkerjaan; while i <= jmldata do set j=1; fetch kursorkerjaan into idkerjaan, kerjaan; open kursorpelaku; while j <= jmldata do fetch kursorpelaku into idnama, nama; select tblrelasi.tarif from tblrelasi, tblpelaku, tblpekerjaan where tblrelasi.idpelaku=tblpelaku.idpelaku and D add column

5 tblrelasi.idpekerjaan = tblpekerjaan.idpekerjaan and tblpelaku.namapelaku = nama and tblpekerjaan.namapekerjaan = kerjaan into angka; tblproses set',kerjaan,'=',angka,'where kolom1 =','"',nama,'"'); PREPARE QUERY EXECUTE QUERY; DEALLOCATE PREPARE QUERY; set j=j+1; close kursorpelaku; set i=i+1; close kursorkerjaan; end; $$ delimiter ; PROCEDURE FIND MINIMUM VALUE IN ROWS delimiter $$ create procedure spfindminimbaris() begin declare i,j,k int default 1; declare minim int default ; declare temp int default 0; declare totalminim int default 0; declare jmldata int; declare totaldata int; declare jmlkolom int; declare namakolom varchar(100); declare namapelaku varchar(100); declare namakolompelaku varchar(100); declare angka int; declare jmlpelaku int; declare x int; declare kursornamakolom cursor for select column_name from information_schema.columns where table_name='tblproses'; declare kursornamabaris cursor for select kolom1 from tblproses; declare kursornilaiminim cursor for select * from tblminimbaris; select count(kolom1) from tblproses into jmlpelaku; select count(*) from information_schema.columns where table_name = 'tblproses' into jmlkolom; select '' as '==========Minim Baris=========='; E

6 open kursornamabaris; while i <= jmlpelaku do fetch kursornamabaris into namapelaku; set j = 1; set minim = ; open kursornamakolom; while j <= jmlkolom do fetch kursornamakolom into namakolom; if (j > 1) then := concat('select ',namakolom,' from tblproses where kolom1="', into angka; set temp = angka; if(minim = ) then set minim = temp; elseif(angka <= minim ) then set minim = angka; set j = j+1; set totalminim = totalminim + minim; insert into tblminimbaris values(minim); close kursornamakolom; set i = i+1; close kursornamabaris; insert into tbltotalnilaiminim values(totalminim); select * from tblminimbaris; end; $$ delimiter ; PROCEDURE NORMALIZE ROW delimiter $$ create procedure spnorrow() begin declare i,j,k int default 1; declare minim int default 0; declare temp int default 0; declare totalminim int default 0; declare jmldata int; F

7 declare totaldata int; declare jmlkolom int; declare namakolom varchar(100); declare namapelaku varchar(100); declare namakolompelaku varchar(100); declare angka int; declare jmlpelaku int; declare x int; declare kursornamakolom cursor for select column_name from information_schema.columns where table_name='tblproses'; declare kursornamabaris cursor for select kolom1 from tblproses; declare kursornilaiminim cursor for select * from tblminimbaris; select count(kolom1) from tblproses into jmlpelaku; select count(*) from information_schema.columns where table_name = 'tblproses' into jmlkolom; select '' as '==========Normalisasi Baris=========='; open kursornamabaris; open kursornilaiminim; while i <= jmlpelaku do fetch kursornamabaris into namapelaku; fetch kursornilaiminim into minim; set k = 1; open kursornamakolom; while k <= jmlkolom do fetch kursornamakolom into namakolom; if (k > 1) then ',namakolom,' from tblproses where kolom1 = "',namapelaku,'" into angka; = concat('update tblproses set ',namakolom,' = (',angka,' ',minim,') where kolom1 = "',namapelaku,'"'); set k = k+1; close kursornamakolom; set i = i+1; G

8 close kursornilaiminim; close kursornamabaris; select * from tblproses; end; $$ delimiter ; PROCEDURE FIND MINIMUM VALUE IN COLUMNS delimiter $$ create procedure spfindminimkolom() begin declare i,j,k int default 1; declare minim int default 0; declare temp int default 0; declare totalminim int default 0; declare jmldata int; declare totaldata int; declare jmlkolom int; declare namakolom varchar(100); declare namapelaku varchar(100); declare namakolompelaku varchar(100); declare angka int; declare jmlpelaku int; declare x int default 0; declare temptotalminim int default 0; declare totb,totk int; declare kursornamakolom cursor for select column_name from information_schema.columns where table_name='tblproses'; declare kursornamabaris cursor for select kolom1 from tblproses; declare kursornilaiminim cursor for select * from tblminimbaris; select '' as '==========Minim Kolom=========='; select count(kolom1) from tblproses into jmlpelaku; select count(*) from information_schema.columns where table_name = 'tblproses' into jmlkolom; open kursornamakolom; while i <= jmlkolom do fetch kursornamakolom into namakolom; if (i > 1) then set j = 1; set minim = ; H

9 open kursornamabaris; while j <= jmlpelaku do fetch kursornamabaris into namapelaku; = concat('select ',namakolom,' from tblproses where kolom1 = into angka; set temp = angka; if(minim = ) then set minim = temp; elseif(angka <= minim ) then set minim = angka; set j = j+1; insert into tblminimkolom values(minim); close kursornamabaris; set i =i+1; close kursornamakolom; select * from tblminimkolom; select sum(nilaiminimkolom) from tblminimkolom into totk; select sum(nilaiminimbaris) from tblminimbaris into totb; set temptotalminim = totb+totk; update tbltotalnilaiminim set totalnilaiminim = temptotalminim; end; $$ delimiter ; PROCEDURE NORMALIZE COLUMN delimiter $$ create procedure spnorcol() begin declare i,j,k int default 1; declare minim int default 0; declare temp int default 0; declare totalminim int default 0; declare jmldata int; declare totaldata int; declare jmlkolom int; declare namakolom varchar(100); declare namapelaku varchar(100); I

10 declare namakolompelaku varchar(100); declare angka int; declare jmlpelaku int; declare x int default 0; declare temptotalminim int default 0; declare totb,totk int; declare kursornamakolom cursor for select column_name from information_schema.columns where table_name='tblproses'; declare kursornamabaris cursor for select kolom1 from tblproses; declare kursornilaiminim cursor for select * from tblminimkolom; select '' as '==========Normalisasi Kolom=========='; select count(kolom1) from tblproses into jmlpelaku; select count(*) from information_schema.columns where table_name = 'tblproses' into jmlkolom; open kursornamakolom; open kursornilaiminim; while i <= jmlkolom do fetch kursornamakolom into namakolom; if (i > 1) then fetch kursornilaiminim into minim; set j = 1; open kursornamabaris; while j <= jmlpelaku do fetch kursornamabaris into namapelaku; = concat('select ',namakolom,' from tblproses where kolom1 = "',namapelaku,'" into angka; = concat('update tblproses set ',namakolom,' = (',angka,' ',minim,') where kolom1 = "',namapelaku,'"'); set j = j+1; close kursornamabaris; set i =i+1; close kursornilaiminim; J

11 close kursornamakolom; select * from tblproses; end; $$ delimiter ; PROCEDURE FIND ZERO VALUE delimiter $$ create procedure spfindnol() begin declare i,j,k int default 1; declare minim int default 0; declare temp int default 0; declare totalminim int default 0; declare jmldata int; declare totaldata int; declare jmlkolom int; declare namakolom varchar(100); declare namapelaku varchar(100); declare namakolompelaku varchar(100); declare angka int; declare jmlpelaku int; declare x int; declare nmpelaku varchar(100); declare nmpekerjaan varchar(100); declare tarifx int; declare kursornamakolom cursor for select column_name from information_schema.columns where table_name='tblproses'; declare kursornamabaris cursor for select kolom1 from tblproses; declare kursornilaiminim cursor for select * from tblminimbaris; select count(kolom1) from tblproses into jmlpelaku; select count(*) from information_schema.columns where table_name = 'tblproses' into jmlkolom; select '' as '==========Find 0=========='; open kursornamabaris; open kursornilaiminim; while i <= jmlpelaku do fetch kursornamabaris into namapelaku; set k = 1; set x = 0; open kursornamakolom; K

12 while k <= jmlkolom do fetch kursornamakolom into namakolom; if(k>1) then = concat('select count(*) from tblproses where kolom1="', namapelaku,'" and ', namakolom,' = 0'); if(@jmldata!=0) then = concat(' select"', namapelaku, '",','"', @tarifx from tblproses where kolom1 = "',namapelaku,'" and ', namakolom,' = 0'); into nmpelaku; into nmpekerjaan; into tarifx; insert into tbltemphasil values(nmpelaku, nmpekerjaan, tarifx); set k = k+1; close kursornamakolom; set i = i+1; close kursornamabaris; select * from tbltemphasil; end; $$ delimiter ; PROCEDURE SORTDATA IN TABLE delimiter $$ create procedure spsorttabletemp() begin declare i,j,k int default 1; declare minim int default 0; declare temp int default 0; declare totalminim int default 0; declare jmldata int; declare totaldata int; declare jmlkolom int; declare jmlpelaku int; declare namakolom varchar(100); L

13 declare namabaris varchar(100); declare angka int; declare jmldatatemphasil int; declare x,y,z int; declare jmlbaris int; declare hasilnama varchar(100); declare hasilpekerjaan varchar(100); declare hasiltarif varchar(100); declare tarifasli int; declare sortpelaku varchar(100); declare nmpelaku varchar(100); declare nmpekerjaan varchar(100); declare tarifx int; declare status varchar(100); declare tmppelaku varchar(100); declare tmppekerjaan varchar(100); declare jmlstatus int default 1; declare kursornamakolom cursor for select column_name from information_schema.columns where table_name='tblproses'; declare kursornamabaris cursor for select kolom1 from tblproses; declare kursornilaiminim cursor for select * from tblminimbaris; declare kursortemphasil cursor for select * from tbltemphasil; declare kursorsortingtemphasil cursor for select namapelaku from tbltemphasil group by namapelaku order by count(namapekerjaan) desc, namapelaku asc; select count(*) from tblproses into jmlbaris; select count(*) from tbltemphasil into jmldatatemphasil; select count(*) from information_schema.columns where table_name = 'tblproses' into jmlkolom; set status= 'salah'; select '' as '==========Sort Data From Max Pekerjaan=========='; open kursorsortingtemphasil; while i<= jmlbaris do fetch kursorsortingtemphasil into sortpelaku; set j = 1; open kursortemphasil; while j<= jmldatatemphasil do fetch kursortemphasil into nmpelaku, nmpekerjaan, tarifx; M

14 if(nmpelaku = sortpelaku) then insert into tblsorttemphasil tarifx); set j = j+1; close kursortemphasil; set i = i+1; close kursorsortingtemphasil; select * from tblsorttemphasil; end; $$ delimiter ; values PROCEDURE INPUT RESULT INTO TABLE RESULT delimiter $$ create procedure spinputintotablehasil() begin declare i,j,k int default 1; declare minim int default 0; declare temp int default 0; declare totalminim int default 0; declare jmldata int; declare totaldata int; declare jmlkolom int; declare jmlpelaku int; declare namakolom varchar(100); declare namabaris varchar(100); declare angka int; declare jmldatatemphasil int; declare x,y,z int; declare jmlbaris int; declare hasilnama varchar(100); declare hasilpekerjaan varchar(100); declare hasiltarif varchar(100); declare tarifasli int; declare sortpelaku varchar(100); declare nmpelaku varchar(100); declare nmpekerjaan varchar(100); declare tarifx int; declare status varchar(100); declare tmppelaku varchar(100); declare tmppekerjaan varchar(100); declare jmlstatus int default 1; N (nmpelaku, nmpekerjaan,

15 declare kursornamakolom cursor for select column_name from information_schema.columns where table_name='tblproses'; declare kursornamabaris cursor for select distinct(namapelaku) from tblsorttemphasil; declare kursornilaiminim cursor for select * from tblminimbaris; declare kursorsorttemphasil cursor for select * from tblsorttemphasil; declare kursormostpekerjaan cursor for select namapelaku from tblsorttemphasil group by namapelaku having count(namapelaku)>1 order by count(namapekerjaan) desc, namapelaku asc; select count(*) from tblproses into jmlbaris; select count(*) from tbltemphasil into jmldatatemphasil; select count(*) from information_schema.columns where table_name = 'tblproses' into jmlkolom; set status= 'salah'; select '' as '==========Input Into Table Hasil=========='; open kursornamabaris; while i<=jmlbaris do fetch kursornamabaris into namabaris; set x = 0; set j = 1; open kursornamakolom; while j<=jmlkolom do fetch kursornamakolom into namakolom; if(j>1) then set y = 0; set k = 1; open kursorsorttemphasil; while k<= jmldatatemphasil do fetch kursorsorttemphasil into nmpelaku, nmpekerjaan, tarifx; select c.tarif from tblrelasi as c, tblpelaku as a, tblpekerjaan as b where c.idpelaku = a.idpelaku and c.idpekerjaan = b.idpekerjaan and a.namapelaku = namabaris and b.namapekerjaan = namakolom into angka; if(namabaris=nmpelaku and namakolom=nmpekerjaan) then select count(*) from tblhasil where namapelaku=namabaris into x; select count(*) from tblhasil where namapekerjaan=namakolom into y; if(x=0) then if(y=0) then O

16 insert into tblhasil values (namabaris, namakolom, angka); set k = k+1; close kursorsorttemphasil; set j = j+1; close kursornamakolom; set i = i+1; close kursornamabaris; select count(counted) into jmldata from ( select namapelaku as counted from tblsorttemphasil group by namapelaku having count(namapelaku)>1 order by count(namapekerjaan) desc ) as Banyak; set i =1; set j =1; open kursormostpekerjaan; while i<= jmldata do fetch kursormostpekerjaan into sortpelaku; set j = 1; open kursorsorttemphasil; while j <= jmldatatemphasil do fetch kursorsorttemphasil into nmpelaku, nmpekerjaan, tarifx; if(nmpelaku = sortpelaku) then insert into tblmostpekerjaan values(nmpelaku, nmpekerjaan); set j = j+1; close kursorsorttemphasil; set i = i+1; close kursormostpekerjaan; select '+=============================+'; select * from tblhasil; end; $$ delimiter ; P

17 PROCEDURE CHECK MATCHING RESULT delimiter $$ create procedure spcheckmatching() begin declare i,j,k int default 1; declare minim int default 0; declare temp int default 0; declare totalminim int default 0; declare jmldata int; declare totaldata int; declare jmlkolom int; declare namakolom varchar(100); declare namabaris varchar(100); declare angka int; declare jmldatatemphasil int; declare jmldatahasil int; declare x,y int; declare jmlbaris int; declare hasilnama varchar(100); declare hasilpekerjaan varchar(100); declare hasiltarif varchar(100); declare tarifasli int; declare nmpelaku varchar(100); declare nmpekerjaan varchar(100); declare tarifx int; declare tmppelaku varchar(100); declare tmppekerjaan varchar(100); declare tmptarif int; declare hslpelaku varchar(100); declare hslpekerjaan varchar(100); declare hsltarif int; declare maksbanyakpekerjaan int; declare status varchar(10); declare kursorsorttemp cursor for select * from tblsorttemphasil; declare kursorhasil cursor for select * from tblhasil; declare kursormostpekerjaan cursor for select * from tblmostpekerjaan; select count(*) from tbltemphasil into jmldatatemphasil; select count(*) from tblhasil into jmldatahasil; select count(*) from tblmostpekerjaan into jmldata; select max(counted) into maksbanyakpekerjaan Q

18 from ( select count(namapekerjaan) as counted from tbltemphasil group by namapelaku ) as MAXIMUM; select '' as '==========Check Matching=========='; open kursormostpekerjaan; while i<= jmldata do fetch kursormostpekerjaan into tmppelaku, tmppekerjaan; set j = 1; open kursorhasil; while j<= jmldatahasil do fetch kursorhasil into hslpelaku, hslpekerjaan, hsltarif; select c.tarif from tblrelasi as c, tblpelaku as a, tblpekerjaan as b where c.idpelaku = a.idpelaku and c.idpekerjaan = b.idpekerjaan and a.namapelaku = tmppelaku and b.namapekerjaan = tmppekerjaan into angka; select count(*) from tblhasil where namapekerjaan=tmppekerjaan into y; if(hslpelaku = tmppelaku) then if(y=0) then select concat(hslpelaku,' dan ',hslpekerjaan,'>>>',tmppelaku,' dan ',tmppekerjaan) as ''; = concat( 'update tblhasil set tarif = ',angka, ', namapekerjaan = "', tmppekerjaan, '" where namapelaku = "',tmppelaku,'"' ); call spinputintotablehasil(); set j = j+1; close kursorhasil; set i = i+1; close kursormostpekerjaan; select * from tblhasil; end; $$ delimiter ; R

19 PROCEDURE FIND SMALLEST VALUE delimiter $$ create procedure spfindsmallest() begin declare i,j,k int default 1; declare minim int default ; declare temp int default 0; declare totalminim int default 0; declare jmldata int; declare totaldata int; declare jmlkolom int; declare namakolom varchar(100); declare namapelaku varchar(100); declare namakolompelaku varchar(100); declare angka int; declare jmlpelaku int; declare x,y,z int; declare xpelaku varchar(100); declare xpekerjaan varchar(100); declare jmlxpelaku int default 0; declare jmlxpekerjaan int default 0; declare xxpelaku varchar(100); declare kursornamakolom cursor for select column_name from information_schema.columns where table_name='tblproses'; declare kursornamabaris cursor for select kolom1 from tblproses; declare kursornilaiminim cursor for select * from tblminimbaris; select count(kolom1) from tblproses into jmlpelaku; select count(*) from information_schema.columns where table_name = 'tblproses' into jmlkolom; select '' as '==========Find Smallest=========='; delete from tblminimbaris; open kursornamabaris; while i <= jmlpelaku do fetch kursornamabaris into xpelaku; concat('select count(*) from tbltemphasil where namapelaku = "', xpelaku,'"'); into x; select xpelaku, x; S

20 concat('select namapelaku from tbltemphasil where namapelaku = "',xpelaku,'" group by namapelaku having count(namapelaku)>1'); into xxpelaku; set j = 1; set minim = ; open kursornamakolom; while j <= jmlkolom do fetch kursornamakolom into xpekerjaan; if (j > 1) then select count(*) into y from tbltemphasil where namapekerjaan = xpekerjaan; count(*) from tblproses where ',xpekerjaan,' = 0 and kolom1!= "',xxpelaku,'" '); into z; if(x<=1) then if(z<=1) then = concat('select ',xpekerjaan, ' from tblproses where kolom1 = "', xpelaku,'" into angka; set temp = angka; if(minim = ) then set minim = temp; elseif(angka <= minim ) then set minim = angka; set j = j+1; insert into tblminimbaris values(minim); close kursornamakolom; select '==============================' as ''; set i = i+1; close kursornamabaris; T

21 select distinct(min(nilaiminimbaris)) from tblminimbaris into z; delete from tblminimbaris; insert into tblminimbaris values(z); update tbltotalnilaiminim set totalnilaiminim = totalnilaiminim + z; select * from tblminimbaris; end; $$ delimiter ; PROCEDURE NORMALIZE MATCHING TABLE delimiter $$ create procedure spnormatch() begin declare i,j,k int default 1; declare minim int default 0; declare temp int default 0; declare totalminim int default 0; declare jmldata int; declare totaldata int; declare jmlkolom int; declare namakolom varchar(100); declare namapelaku varchar(100); declare namakolompelaku varchar(100); declare angka int; declare jmlpelaku int; declare x,y,z int; declare xpelaku varchar(100); declare xpekerjaan varchar(100); declare xxpelaku varchar(100); declare kursornamakolom cursor for select column_name from information_schema.columns where table_name='tblproses'; declare kursornamabaris cursor for select kolom1 from tblproses; declare kursornilaiminim cursor for select * from tblminimbaris; select count(kolom1) from tblproses into jmlpelaku; select count(*) from information_schema.columns where table_name = 'tblproses' into jmlkolom; select * from tblminimbaris into minim; select '' as '==========Normalisasi Tabel Matching=========='; U

22 open kursornamabaris; while i <= jmlpelaku do fetch kursornamabaris into xpelaku; concat('select count(*) from tbltemphasil where namapelaku = "', xpelaku,'"'); into x; concat('select namapelaku from tbltemphasil where namapelaku = "',xpelaku,'" group by namapelaku having count(namapelaku)>1'); into xxpelaku; set k = 1; open kursornamakolom; while k <= jmlkolom do fetch kursornamakolom into xpekerjaan; if (k > 1) then select count(*) from tbltemphasil where namapekerjaan = xpekerjaan into y; count(*) from tblproses where ',xpekerjaan,' = 0 and kolom1!="',xxpelaku,'" '); into z; if(x<=1) then if(z<=1) then = concat('select ',xpekerjaan, ' from tblproses where kolom1 = "', xpelaku,'" into angka; = concat('update tblproses set ', xpekerjaan,' = (',angka,' ',minim, ) where kolom1= "',xpelaku,'"'); else if(z>1) then V

23 = concat('select ',xpekerjaan, ' from tblproses where kolom1 = "', xpelaku,'" into angka; = concat('update tblproses set ', xpekerjaan,' = (',angka,'+',minim, where kolom1= "',xpelaku,'"'); set k = k+1; close kursornamakolom; set i = i+1; close kursornamabaris; select * from tblproses; end; $$ delimiter ; index.php INDEX PAGE <!DOCTYPE html> <html> <head> <title>hungarian dengan Stored Procedure</title> </head> <body> <form action="savetodatabase.php" method="post"> Jumlah Data<input type="text" size="2" name="data"> <br> <button type="submit" name="submit">make Table</button> </form> </body> </html> savetodatabase.php CONNECT TO DATABASE <?php $conn; W

24 $servername = "localhost"; $username = "root"; $password = "abcdef"; try $conn = new PDO("mysql:host=$servername;dbname=dbSkripsi", $username, $password); $conn >setattribute(pdo::attr_errmode, PDO::ERRMODE_EXCEPTION); GENERATE WORKER AND JOB AUTOMATICALLY $row = $_POST["data"]; $col = $_POST["data"]; $prosesquery = 'call spfirsttimerunning()'; $result = $conn >query($prosesquery); $result >setfetchmode(pdo::fetch_assoc); $result >closecursor(); $relasi = 'delete from tblrelasi'; $result = $conn >query($relasi); $pelaku = 'delete from tblpelaku'; $result = $conn >query($pelaku); $pekerjaan = 'delete from tblpekerjaan'; $result = $conn >query($pekerjaan); $x = 1; /*pekerjaan*/ for($i=0;$i<$row;$i++) $sql = 'insert into tblpekerjaan values ("'.$x.'", $result = $conn >query($sql); $x=$x+1; $x = 1; /*pelaku*/ for($i=0;$i<$row;$i++) $sql = 'insert into tblpelaku values ("'.$x.'" $x).'")'; $result = $conn >query($sql); $x=$x+1; /*relasi*/ $prosesquery3 = 'call spgenerateangka('.$row.')'; $result3 = $conn >query($prosesquery3); $result3 >setfetchmode(pdo::fetch_assoc); $result3 >closecursor(); header("location:proses.php"); X "x'.$x.'")';, "'.chr(64+

25 catch(pdoexception $e) echo "Connection GAGAL: ". $e >getmessage();?> proses.php MAIN PROGRAM <!DOCTYPE html> <html> <head> <title>hungarian dengan Stored Procedure</title> </head> <body> <?php $conn; $servername = "localhost"; $username = "root"; $password = "abcdef"; try $conn = new PDO("mysql:host=$servername;dbname=dbSkripsi", $username, $password); $conn >setattribute(pdo::attr_errmode, PDO::ERRMODE_EXCEPTION); /*=================================================*/ $prosesquery1 = 'call spinputintotable()'; $result1 = $conn >query($prosesquery1); $result1 >setfetchmode(pdo::fetch_assoc); $result1 >closecursor(); /* tblproses */ $querypekerjaan = 'select * from tblpekerjaan'; $resultpekerjaan = $conn >query($querypekerjaan); $pekerjaan = $resultpekerjaan >fetchall(); $queryproses = 'select * from tblproses'; $resultproses = $conn >query($queryproses); $proses = $resultproses >fetchall(); $queryjmldata = 'select count(*) from tblpekerjaan'; $resultjmldata = $conn >query($queryjmldata); $x = $resultjmldata >fetchall(); $jmlpekerjaan = $x[0][0];?>data Awal<? echo "<br><table border='1'>"; echo "<tr><td></td>"; Y

26 for($i=0;$i<$jmlpekerjaan;$i++) echo "<td>".$pekerjaan[$i][1]."</td>"; echo "</tr>"; for($i=0;$i<$jmlpekerjaan;$i++) echo "<tr>"; for($j=0;$j<($jmlpekerjaan+1);$j++) echo "<td>".$proses[$i][$j]."</td>"; echo "</tr>"; echo "</table><br><br>"; /*================================================*/ $prosesquery2 = 'call spfindminimbaris()'; $result2 = $conn >query($prosesquery2); $result2 >setfetchmode(pdo::fetch_assoc); $result2 >closecursor(); /* tblminimbaris */ $query = 'select * from tblminimbaris'; $result = $conn >query($query);?>nilai Minim Baris<? echo "<br><table border='1'>"; echo "<tr> <td>nilai Minim</td> </tr>"; while($row = $result >fetch()) echo "<tr><td>".$row['nilaiminimbaris']."</td></tr>"; echo "</table><br><br>"; /*===========================================*/ $prosesquery3 = 'call spnorrow()'; $result3 = $conn >query($prosesquery3); $result3 >setfetchmode(pdo::fetch_assoc); $result3 >closecursor(); /* tblproses */ $querypekerjaan = 'select * from tblpekerjaan'; $resultpekerjaan = $conn >query($querypekerjaan); $pekerjaan = $resultpekerjaan >fetchall(); $queryproses = 'select * from tblproses'; $resultproses = $conn >query($queryproses); $proses = $resultproses >fetchall(); Z

27 $queryjmldata = 'select count(*) from tblpekerjaan'; $resultjmldata = $conn >query($queryjmldata); $x = $resultjmldata >fetchall(); $jmlpekerjaan = $x[0][0];?>normalisasi Baris<? echo "<br><table border='1'>"; echo "<tr><td></td>"; for($i=0;$i<$jmlpekerjaan;$i++) echo "<td>".$pekerjaan[$i][1]."</td>"; echo "</tr>"; for($i=0;$i<$jmlpekerjaan;$i++) echo "<tr>"; for($j=0;$j<($jmlpekerjaan+1);$j++) echo "<td>".$proses[$i][$j]."</td>"; echo "</tr>"; echo "</table><br><br>"; /*==========================================*/ $prosesquery4 = 'call spfindminimkolom()'; $result4 = $conn >query($prosesquery4); $result4 >setfetchmode(pdo::fetch_assoc); $result4 >closecursor(); /* tblminimkolom */ $query = 'select * from tblminimkolom'; $result = $conn >query($query);?>nilai Minim Kolom<? echo "<br><table border='1'>"; echo "<tr> <td>nilai Minim</td> </tr>"; while($row = $result >fetch()) echo "<tr><td>".$row['nilaiminimkolom']."</td></tr>"; echo "</table><br><br>"; /*===========================================*/ $prosesquery5 = 'call spnorcol()'; $result5 = $conn >query($prosesquery5); $result5 >setfetchmode(pdo::fetch_assoc); $result5 >closecursor(); AA

28 /* tblproses */ $querypekerjaan = 'select * from tblpekerjaan'; $resultpekerjaan = $conn >query($querypekerjaan); $pekerjaan = $resultpekerjaan >fetchall(); $queryproses = 'select * from tblproses'; $resultproses = $conn >query($queryproses); $proses = $resultproses >fetchall(); $queryjmldata = 'select count(*) from tblpekerjaan'; $resultjmldata = $conn >query($queryjmldata); $x = $resultjmldata >fetchall(); $jmlpekerjaan = $x[0][0];?>normalisasi Kolom<? echo "<br><table border='1'>"; echo "<tr><td></td>"; for($i=0;$i<$jmlpekerjaan;$i++) echo "<td>".$pekerjaan[$i][1]."</td>"; echo "</tr>"; for($i=0;$i<$jmlpekerjaan;$i++) echo "<tr>"; for($j=0;$j<($jmlpekerjaan+1);$j++) echo "<td>".$proses[$i][$j]."</td>"; echo "</tr>"; echo "</table><br><br>"; /*==========================================*/ $prosesquery6 = 'call spfindnol()'; $result6 = $conn >query($prosesquery6); $result6 >setfetchmode(pdo::fetch_assoc); $result6 >closecursor(); /* tbltemphasil */ $query = 'select * from tbltemphasil'; $result = $conn >query($query);?>mencari Nilai 0<? echo "<table border='1'>"; echo "<tr> <td>nama Pelaku</td> <td>nama Pekerjaan</td> <td>nilai</td> </tr>"; AB

29 while($row = $result >fetch()) echo "<tr><td>".$row['namapelaku']."</td>"; echo "<td>".$row['namapekerjaan']."</td>"; echo "<td>".$row['tarif']."</td></tr>"; echo "</table><br><br>"; /*=================================================*/ $prosesquery7 = 'call spsorttabletemp()'; $result7 = $conn >query($prosesquery7); $result7 >setfetchmode(pdo::fetch_assoc); $result7 >closecursor(); /* tblsorttemphasil */ $query = 'select * from tblsorttemphasil'; $result = $conn >query($query);?>sorting Count(nilai 0)>1 DESC<? echo "<table border='1'>"; echo "<tr> <td>nama Pelaku</td> <td>nama Pekerjaan</td> <td>nilai</td> </tr>"; while($row = $result >fetch()) echo "<tr><td>".$row['namapelaku']."</td>"; echo "<td>".$row['namapekerjaan']."</td>"; echo "<td>".$row['tarif']."</td></tr>"; echo "</table><br><br>"; /*=================================================*/ $prosesquery8 = 'call spinputintotablehasil()'; $result8 = $conn >query($prosesquery8); $result8 >setfetchmode(pdo::fetch_assoc); $result8 >closecursor(); /* tblhasil */ $query = 'select * from tblhasil'; $result = $conn >query($query);?>input data ke dalam tabel hasil<? echo "<table border='1'>"; echo "<tr> <td>nama Pelaku</td> <td>nama Pekerjaan</td> <td>nilai</td> </tr>"; AC

30 while($row = $result >fetch()) echo "<tr><td>".$row['namapelaku']."</td>"; echo "<td>".$row['namapekerjaan']."</td>"; echo "<td>".$row['tarif']."</td></tr>"; echo "</table><br><br>"; /*======================================*/ $prosesquery9 = 'call spcheckmatching()'; $result9 = $conn >query($prosesquery9); $result9 >setfetchmode(pdo::fetch_assoc); $result9 >closecursor(); /* tblhasil */ $query = 'select * from tblhasil'; $result = $conn >query($query);?>check kecocokan<? echo "<table border='1'>"; echo "<tr> <td>nama Pelaku</td> <td>nama Pekerjaan</td> <td>nilai</td> </tr>"; while($row = $result >fetch()) echo "<tr><td>".$row['namapelaku']."</td>"; echo "<td>".$row['namapekerjaan']."</td>"; echo "<td>".$row['tarif']."</td></tr>"; echo "</table><br><br>"; /*======================================*/ /*...*/ $status='salah'; $querypekerjaan = 'select * from tblpekerjaan'; $resultpekerjaan = $conn >query($querypekerjaan); $pekerjaan = $resultpekerjaan >fetchall(); $queryproses = 'select * from tblproses'; $resultproses = $conn >query($queryproses); $proses = $resultproses >fetchall(); $queryjmldata = 'select count(*) from tblpekerjaan'; $resultjmldata = $conn >query($queryjmldata); $x = $resultjmldata >fetchall(); $jmlpekerjaan = $x[0][0]; $queryjmlhasil = 'select count(*) from tblhasil'; $resultjmlhasil = $conn >query($queryjmlhasil); $x = $resultjmlhasil >fetchall(); AD

31 $jmlhasil = $x[0][0]; /*...*/ if($jmlhasil < $jmlpekerjaan) echo " "."<br><br>"; while($status='salah') $queryjmldata = 'select count(*) from tblpekerjaan'; $resultjmldata = $conn >query($queryjmldata); $x = $resultjmldata >fetchall(); $jmlpekerjaan = $x[0][0]; $queryjmlhasil = 'select count(*) from tblhasil'; $resultjmlhasil = $conn >query($queryjmlhasil); $x = $resultjmlhasil >fetchall(); $jmlhasil = $x[0][0]; /*=========================================*/ $prosesquery10 = 'call spfindsmallest()'; $result10 = $conn >query($prosesquery10); $result10 >setfetchmode(pdo::fetch_assoc); $result10 >closecursor(); /* tblminimbaris */ $query = 'select * from tblminimbaris'; $result = $conn >query($query);?>nilai Smallest<? echo "<br><table border='1'>"; echo "<tr> <td>nilai Minim</td> </tr>"; while($row = $result >fetch()) echo "<tr><td>".$row['nilaiminimbaris']."</td></tr>"; echo "</table><br><br>"; /*===========================================*/ $prosesquery11 = 'call spnormatch()'; $result11 = $conn >query($prosesquery11); $result11 >setfetchmode(pdo::fetch_assoc); $result11 >closecursor(); /* tblproses */ $querypekerjaan = 'select * from tblpekerjaan'; $resultpekerjaan = $conn >query($querypekerjaan); $pekerjaan = $resultpekerjaan >fetchall(); $queryproses = 'select * from tblproses'; $resultproses = $conn >query($queryproses); $proses = $resultproses >fetchall(); AE

32 $queryjmldata = 'select count(*) from tblpekerjaan'; $resultjmldata = $conn >query($queryjmldata); $x = $resultjmldata >fetchall(); $jmlpekerjaan = $x[0][0];?>normalisasi Matching<? echo "<br><table border='1'>"; echo "<tr><td></td>"; for($i=0;$i<$jmlpekerjaan;$i++) echo "<td>".$pekerjaan[$i][1]."</td>"; echo "</tr>"; for($i=0;$i<$jmlpekerjaan;$i++) echo "<tr>"; for($j=0;$j<($jmlpekerjaan+1);$j++) echo "<td>".$proses[$i][$j]."</td>"; echo "</tr>"; echo "</table><br><br>"; /*==========================================*/ $prosesquery12 = 'call spfindnol()'; $result12 = $conn >query($prosesquery12); $result12 >setfetchmode(pdo::fetch_assoc); $result12 >closecursor(); /* tbltemphasil */ $query = 'select * from tbltemphasil'; $result = $conn >query($query);?>mencari Nilai 0<? echo "<table border='1'>"; echo "<tr> <td>nama Pelaku</td> <td>nama Pekerjaan</td> <td>nilai</td> </tr>"; while($row = $result >fetch()) echo "<tr><td>".$row['namapelaku']."</td>"; echo "<td>".$row['namapekerjaan']."</td>"; echo "<td>".$row['tarif']."</td></tr>"; echo "</table><br><br>"; /*=================================================*/ AF

33 $prosesquery13 = 'call spsorttabletemp()'; $result13 = $conn >query($prosesquery13); $result13 >setfetchmode(pdo::fetch_assoc); $result13 >closecursor(); /* tblsorttemphasil */ $query = 'select * from tblsorttemphasil'; $result = $conn >query($query);?>sorting Count(nilai 0)>1 DESC<? echo "<table border='1'>"; echo "<tr> <td>nama Pelaku</td> <td>nama Pekerjaan</td> <td>nilai</td> </tr>"; while($row = $result >fetch()) echo "<tr><td>".$row['namapelaku']."</td>"; echo "<td>".$row['namapekerjaan']."</td>"; echo "<td>".$row['tarif']."</td></tr>"; echo "</table><br><br>"; /*=================================================*/ $prosesquery14 = 'call spinputintotablehasil()'; $result14 = $conn >query($prosesquery14); $result14 >setfetchmode(pdo::fetch_assoc); $result14 >closecursor(); /* tblhasil */ $query = 'select * from tblhasil'; $result = $conn >query($query);?>check kecocokan<? echo "<table border='1'>"; echo "<tr> <td>nama Pelaku</td> <td>nama Pekerjaan</td> <td>nilai</td> </tr>"; while($row = $result >fetch()) echo "<tr><td>".$row['namapelaku']."</td>"; echo "<td>".$row['namapekerjaan']."</td>"; echo "<td>".$row['tarif']."</td></tr>"; echo "</table><br><br>"; /*======================================*/ $prosesquery15 = 'call spcheckmatching()'; AG

34 $result15 = $conn >query($prosesquery15); $result15 >setfetchmode(pdo::fetch_assoc); $result15 >closecursor(); /* tblhasil */ $query = 'select * from tblhasil'; $result = $conn >query($query);?>check kecocokan<? echo "<table border='1'>"; echo "<tr> <td>nama Pelaku</td> <td>nama Pekerjaan</td> <td>nilai</td> </tr>"; while($row = $result >fetch()) echo "<tr><td>".$row['namapelaku']."</td>"; echo "<td>".$row['namapekerjaan']."</td>"; echo "<td>".$row['tarif']."</td></tr>"; echo "</table><br><br>"; /*======================================*/ if($jmlhasil == $jmlpekerjaan) $status='benar'; /* tblproses */ echo "D O N E!"."<br><br>"; echo " H A S I L "."<br><br>"; /* tblhasil */ $query = 'select * from tblhasil'; $result = $conn >query($query); echo "<table border='1'>"; echo "<tr> <td>nama Pelaku</td> <td>nama Pekerjaan</td> <td>nilai</td> </tr>"; while($row = $result >fetch()) echo "<tr><td>".$row['namapelaku']."</td>"; echo "<td>".$row['namapekerjaan']."</td>"; echo "<td>".$row['tarif']."</td></tr>"; AH

35 echo "</table><br><br>"; /*======================================*/?><a href="index.php">index</a><? catch(pdoexception $e) echo "Connection GAGAL: ". $e >getmessage();?> </body> </html> AI

36 AJ

37 AK

APLIKACJE INTERNETOWE 8 PHP WYKORZYSTANIE BAZY DANYCH MYSQL

APLIKACJE INTERNETOWE 8 PHP WYKORZYSTANIE BAZY DANYCH MYSQL APLIKACJE INTERNETOWE 8 PHP WYKORZYSTANIE BAZY DANYCH MYSQL PLAN PREZENTACJI Bazy danych w PHP Połączenie z bazą danych Zamknięcie połączenie Tworzenie bazy danych Tworzenie tabeli Operacje na tabelach

More information

What is MySQL? [Document provides the fundamental operations of PHP-MySQL connectivity]

What is MySQL? [Document provides the fundamental operations of PHP-MySQL connectivity] What is MySQL? [Document provides the fundamental operations of PHP-MySQL connectivity] MySQL is a database. A database defines a structure for storing information. In a database, there are tables. Just

More information

Database Connectivity using PHP Some Points to Remember:

Database Connectivity using PHP Some Points to Remember: Database Connectivity using PHP Some Points to Remember: 1. PHP has a boolean datatype which can have 2 values: true or false. However, in PHP, the number 0 (zero) is also considered as equivalent to False.

More information

PHP Development - Introduction

PHP Development - Introduction PHP Development - Introduction Php Hypertext Processor PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports many

More information

Web Application Development (WAD) V th Sem BBAITM (Unit 4) By: Binit Patel

Web Application Development (WAD) V th Sem BBAITM (Unit 4) By: Binit Patel Web Application Development (WAD) V th Sem BBAITM (Unit 4) By: Binit Patel Working with Forms: A very popular way to make a web site interactive is using HTML based forms by the site. Using HTML forms,

More information

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Princess Nourah bint Abdulrahman University. Computer Sciences Department Princess Nourah bint Abdulrahman University Computer Sciences Department 1 And use http://www.w3schools.com/ PHP Part 3 Objectives Creating a new MySQL Database using Create & Check connection with Database

More information

Chapters 10 & 11 PHP AND MYSQL

Chapters 10 & 11 PHP AND MYSQL Chapters 10 & 11 PHP AND MYSQL Getting Started The database for a Web app would be created before accessing it from the web. Complete the design and create the tables independently. Use phpmyadmin, for

More information

Unit 1 - Chapter 4,5

Unit 1 - Chapter 4,5 Unit 1 - Chapter 4,5 CREATE DATABASE DatabaseName; SHOW DATABASES; USE DatabaseName; DROP DATABASE DatabaseName; CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype,... columnn

More information

How to use PHP with a MySQL database

How to use PHP with a MySQL database Chapter 4 How to use PHP with a MySQL database The syntax for creating an object from any class new ClassName(arguments); The syntax for creating a database object from the PDO class new PDO($dsn, $username,

More information

Advanced Web Programming Practice Exam II

Advanced Web Programming Practice Exam II Advanced Web Programming Practice Exam II Name: 12 December 2017 This is a closed book exam. You may use one sheet of notes (8.5X11in, front only) but cannot use any other references or electronic device.

More information

By the end of this section of the practical, the students should be able to:

By the end of this section of the practical, the students should be able to: By the end of this section of the practical, the students should be able to: Connecting to a MySQL database in PHP with the mysql_connect() and mysql_select_db() functions Trapping and displaying database

More information

SQL stands for Structured Query Language. SQL lets you access and manipulate databases

SQL stands for Structured Query Language. SQL lets you access and manipulate databases CMPSC 117: WEB DEVELOPMENT SQL stands for Structured Query Language SQL lets you access and manipulate databases SQL is an ANSI (American National Standards Institute) standard 1 SQL can execute queries

More information

Using PHP with MYSQL

Using PHP with MYSQL Using PHP with MYSQL PHP & MYSQL So far you've learned the theory behind relational databases and worked directly with MySQL through the mysql command-line tool. Now it's time to get your PHP scripts talking

More information

Use of PHP for DB Connection. Middle and Information Tier. Middle and Information Tier

Use of PHP for DB Connection. Middle and Information Tier. Middle and Information Tier Use of PHP for DB Connection 1 2 Middle and Information Tier PHP: built in library functions for interfacing with the mysql database management system $id = mysqli_connect(string hostname, string username,

More information

IS 2150 / TEL 2810 Introduction to Security

IS 2150 / TEL 2810 Introduction to Security IS 2150 / TEL 2810 Introduction to Security James Joshi Professor, SIS Lecture 15 April 20, 2016 SQL Injection Cross-Site Scripting 1 Goals Overview SQL Injection Attacks Cross-Site Scripting Attacks Some

More information

References webharvy mysql

References webharvy mysql References 1. https://www.dfki.de/web/research/publications/renamefilefordownload?...25... 2. MK Dalal, MA Zaveri - Applied computational intelligence and soft, 2014 - dl.acm.org 3. http://www.aclweb.org/anthology/w10-3209

More information

PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008.

PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008. PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008. Outline. How cookies work. Cookies in PHP. Sessions. Databases. Cookies. Sometimes it is useful to remember a client when it comes

More information

Secure Web-Based Systems Fall Test 1

Secure Web-Based Systems Fall Test 1 Secure Web-Based Systems Fall 2016 CS 4339 Professor L. Longpré Name: Directions: Test 1 This test is closed book and closed notes. However, you may consult the special cheat sheet provided to you with

More information

Web Programming. Dr Walid M. Aly. Lecture 10 PHP. lec10. Web Programming CS433/CS614 22:32. Dr Walid M. Aly

Web Programming. Dr Walid M. Aly. Lecture 10 PHP. lec10. Web Programming CS433/CS614 22:32. Dr Walid M. Aly Web Programming Lecture 10 PHP 1 Purpose of Server-Side Scripting database access Web page can serve as front-end to a database Ømake requests from browser, Øpassed on to Web server, Øcalls a program to

More information

Professional PHP for working with MySQL

Professional PHP for working with MySQL Chapter 19 Professional PHP for working with MySQL PDO (PHP Data Objects) Pros Is included with PHP 5.1 and later and available for 5.0. Provides an object-oriented interface. Provides a consistent interface

More information

CSC Web Programming. Introduction to SQL

CSC Web Programming. Introduction to SQL CSC 242 - Web Programming Introduction to SQL SQL Statements Data Definition Language CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE Data Query Language SELECT SQL statements end with

More information

Lab 7 Introduction to MySQL

Lab 7 Introduction to MySQL Lab 7 Introduction to MySQL Objectives: During this lab session, you will - Learn how to access the MySQL Server - Get hand-on experience on data manipulation and some PHP-to-MySQL technique that is often

More information

CPET 499/ITC 250 Web Systems

CPET 499/ITC 250 Web Systems CPET 499/ITC 250 Web Systems Chapter 11 Working with Databases Part 2 of 3 Text Book: * Fundamentals of Web Development, 2015, by Randy Connolly and Ricardo Hoar, published by Pearson Paul I-Hai, Professor

More information

LAMPIRAN. Index.php. <?php. unset($_session["status"]); //session_destroy(); //session_destroy();

LAMPIRAN. Index.php. <?php. unset($_session[status]); //session_destroy(); //session_destroy(); LAMPIRAN Index.php unset($_session["status"]); //session_destroy(); //session_destroy();?>

More information

If Only. More SQL and PHP

If Only. More SQL and PHP If Only More SQL and PHP PHP: The if construct If only I could conditionally select PHP statements to execute. That way, I could have certain actions happen only under certain circumstances The if statement

More information

Web Systems Nov. 2, 2017

Web Systems Nov. 2, 2017 Web Systems Nov. 2, 2017 Topics of Discussion Using MySQL as a Calculator Command Line: Create a Database, a Table, Insert Values into Table, Query Database Using PhP API to Interact with MySQL o Check_connection.php

More information

PHP Introduction. Some info on MySQL which we will cover in the next workshop...

PHP Introduction. Some info on MySQL which we will cover in the next workshop... PHP and MYSQL PHP Introduction PHP is a recursive acronym for PHP: Hypertext Preprocessor -- It is a widely-used open source general-purpose serverside scripting language that is especially suited for

More information

Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015

Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015 Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015 PHP Arrays o Arrays are single variables that store multiple values at the same time! o Consider having a list of values

More information

COMP519: Web Programming Autumn 2015

COMP519: Web Programming Autumn 2015 COMP519: Web Programming Autumn 2015 In the next lectures you will learn What is SQL How to access mysql database How to create a basic mysql database How to use some basic queries How to use PHP and mysql

More information

4) PHP and MySQL. Emmanuel Benoist. Spring Term Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1

4) PHP and MySQL. Emmanuel Benoist. Spring Term Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1 4) PHP and MySQL Emmanuel Benoist Spring Term 2017 Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1 PHP and MySQL Introduction Basics of MySQL Create a Table See

More information

Use of PHP for DB Connection. Middle and Information Tier

Use of PHP for DB Connection. Middle and Information Tier Client: UI HTML, JavaScript, CSS, XML Use of PHP for DB Connection Middle Get all books with keyword web programming PHP Format the output, i.e., data returned from the DB SQL DB Query Access/MySQL 1 2

More information

CMPS 401 Survey of Programming Languages

CMPS 401 Survey of Programming Languages CMPS 401 Survey of Programming Languages Programming Assignment #4 PHP Language On the Ubuntu Operating System Write a PHP program (P4.php) and create a HTML (P4.html) page under the Ubuntu operating system.

More information

The connection has timed out

The connection has timed out 1 of 7 2/17/2018, 7:46 AM Mukesh Chapagain Blog PHP Magento jquery SQL Wordpress Joomla Programming & Tutorial HOME ABOUT CONTACT ADVERTISE ARCHIVES CATEGORIES MAGENTO Home» PHP PHP: CRUD (Add, Edit, Delete,

More information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Review Content Management (cont.) Replace all txt files with database tables Expand PHP/MySQL SELECT, UPDATE & DELETE queries Permit full editorial control over content

More information

School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University

School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University ITS351 Database Programming Laboratory Laboratory #9: PHP & Form Processing III Objective:

More information

Systems Programming & Scripting

Systems Programming & Scripting Systems Programming & Scripting Lecture 19: Database Support Sys Prog & Scripting - HW Univ 1 Typical Structure of a Web Application Client Internet Web Server Application Server Database Server Third

More information

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014 The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014 MySQL Setup, using console Data types Overview Creating users, databases and tables SQL queries INSERT, SELECT, DELETE WHERE, ORDER

More information

Databases (MariaDB/MySQL) CS401, Fall 2015

Databases (MariaDB/MySQL) CS401, Fall 2015 Databases (MariaDB/MySQL) CS401, Fall 2015 Database Basics Relational Database Method of structuring data as tables associated to each other by shared attributes. Tables (kind of like a Java class) have

More information

Development Technologies. Agenda: phpmyadmin 2/20/2016. phpmyadmin MySQLi. Before you can put your data into a table, that table should exist.

Development Technologies. Agenda: phpmyadmin 2/20/2016. phpmyadmin MySQLi. Before you can put your data into a table, that table should exist. CIT 736: Internet and Web Development Technologies Lecture 10 Dr. Lupiana, DM FCIM, Institute of Finance Management Semester 1, 2016 Agenda: phpmyadmin MySQLi phpmyadmin Before you can put your data into

More information

LAB 11 WORKING WITH DATABASES

LAB 11 WORKING WITH DATABASES LAB 11 WORKING WITH DATABASES What You Will Learn How to install and manage a MySQL database How to use SQL queries in you PHP code How to integrate user inputs into SQL queries How to manage files inside

More information

Hello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL.

Hello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL. Hello everyone! Welcome to our PHP + MySQL (Easy to learn) E.T.L. free online course Hope you have installed your XAMPP? And you have created your forms inside the studio file in the htdocs folder using

More information

API Documentation for PHP Clients

API Documentation for PHP Clients Introducing the Gold Lasso API API Documentation for PHP Clients The eloop API provides programmatic access to your organization s information using a simple, powerful, and secure application programming

More information

CSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus

CSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus CSCI-UA:0060-02 Database Design & Web Implementation Professor Evan Sandhaus sandhaus@cs.nyu.edu evan@nytimes.com Lecture #28: This is the end - the only end my friends. Database Design and Web Implementation

More information

P - 13 Bab 10 : PHP MySQL Lanjut (Studi Kasus)

P - 13 Bab 10 : PHP MySQL Lanjut (Studi Kasus) P - 13 Bab 10 : PHP MySQL Lanjut (Studi Kasus) 10.1 Tujuan Mahasiswa mampu : Mengetahui dan Memahami Integrasi PHP dengan MySQL Mengetahui dan Memahami Relasi Dengan phpmyadmin Designer Mengetahui dan

More information

Chapter 10: MySQL & PHP. PHP and MySQL CIS 86 Mission College

Chapter 10: MySQL & PHP. PHP and MySQL CIS 86 Mission College Chapter 10: MySQL & PHP PHP and MySQL CIS 86 Mission College Tonight s agenda Drop the class? Login file Connecting to a MySQL database Object-oriented PHP Executing a query Fetching a result Fetching

More information

Greetings West Ada Comp Sci TAC & Friends,

Greetings West Ada Comp Sci TAC & Friends, Greetings West Ada Comp Sci TAC & Friends, Thank you for taking time from your busy schedules to attend our Technical Advisors Meeting (TAC) last Wed: Two teachers, five industry reps. Your inputs directly

More information

PHP Tutorial 6(a) Using PHP with MySQL

PHP Tutorial 6(a) Using PHP with MySQL Objectives After completing this tutorial, the student should have learned; The basic in calling MySQL from PHP How to display data from MySQL using PHP How to insert data into MySQL using PHP Faculty

More information

Web Security. Attacks on Servers 11/6/2017 1

Web Security. Attacks on Servers 11/6/2017 1 Web Security Attacks on Servers 11/6/2017 1 Server side Scripting Javascript code is executed on the client side on a user s web browser Server side code is executed on the server side. The server side

More information

CS4604 Prakash Spring 2016! Project 3, HTML and PHP. By Sorour Amiri and Shamimul Hasan April 20 th, 2016

CS4604 Prakash Spring 2016! Project 3, HTML and PHP. By Sorour Amiri and Shamimul Hasan April 20 th, 2016 CS4604 Prakash Spring 2016! Project 3, HTML and PHP By Sorour Amiri and Shamimul Hasan April 20 th, 2016 Project 3 Outline 1. A nice web interface to your database. (HTML) 2. Connect to database, issue,

More information

Pratikum 8. Membuat Transaksi Penjualan

Pratikum 8. Membuat Transaksi Penjualan Pratikum 8 Membuat Transaksi Penjualan Transaksi adalah Hubungan tabel satu dengan yang lain menjadi sebuah form, di dalam form tersebut mengambil beberapa field dari tabel lain sehingga menjadi satu inputan.

More information

COM1004 Web and Internet Technology

COM1004 Web and Internet Technology COM1004 Web and Internet Technology When a user submits a web form, how do we save the information to a database? How do we retrieve that data later? ID NAME EMAIL MESSAGE TIMESTAMP 1 Mike mike@dcs Hi

More information

home.php 1/1 lectures/6/src/ include.php 1/1 lectures/6/src/

home.php 1/1 lectures/6/src/ include.php 1/1 lectures/6/src/ home.php 1/1 3: * home.php 5: * A simple home page for these login demos. 6: * David J. Malan 8: * Computer Science E-75 9: * Harvard Extension School 10: */ 11: // enable sessions 13: session_start();

More information

Understanding Basic SQL Injection

Understanding Basic SQL Injection Understanding Basic SQL Injection SQL injection (also known as SQLI) is a code injection technique that occurs if the user-defined input data is not correctly filtered or sanitized of the string literal

More information

Lecture 7 Stored procedure

Lecture 7 Stored procedure ITM-661 ระบบฐานข อม ล (Database system) Walailak - 2013 Lecture 7 Stored procedure Walailak University T. Connolly, and C. Begg, Database Systems: A Practical Approach to Design, Implementation, and Management,

More information

Running SQL in Java and PHP

Running SQL in Java and PHP Running SQL in Java and PHP FCDB 9.6 9.7 Dr. Chris Mayfield Department of Computer Science James Madison University Feb 28, 2018 Introduction to JDBC JDBC = Java Database Connectivity 1. Connect to the

More information

LAMP Apps. Overview. Learning Outcomes: At the completion of the lab you should be able to:

LAMP Apps. Overview. Learning Outcomes: At the completion of the lab you should be able to: LAMP Apps Overview This lab walks you through using Linux, Apache, MySQL and PHP (LAMP) to create simple, yet very powerful PHP applications connected to a MySQL database. For developers using Windows,

More information

Chapter 7 PHP Files & MySQL Databases

Chapter 7 PHP Files & MySQL Databases Chapter 7 PHP Files & MySQL Databases At the end of the previous chapter, a simple calendar was displayed with an appointment. This demonstrated again how forms can be used to pass data from one page to

More information

IBM i. IBM i Access Client Solutions Linux ODBC Linux Web

IBM i. IBM i Access Client Solutions Linux ODBC Linux Web Linux ODBC Web IBM i IBM i IBM i Web IBM i Access Client Solutions Linux ODBC Linux Web IBM i IBM i [ ] IBM i IBM i 2012 12 154 KB http://www-06.ibm.com/systems/jp/power/software/i/seminar/pdf/iseminar_201212_data-exchange.pdf

More information

Options. Real SQL Programming 1. Stored Procedures. Embedded SQL

Options. Real SQL Programming 1. Stored Procedures. Embedded SQL Real 1 Options We have seen only how SQL is used at the generic query interface an environment where we sit at a terminal and ask queries of a database. Reality is almost always different: conventional

More information

Chapter 1 An introduction to relational databases and SQL

Chapter 1 An introduction to relational databases and SQL Chapter 1 An introduction to relational databases and SQL Murach's MySQL, C1 2015, Mike Murach & Associates, Inc. Slide 1 Objectives Knowledge Identify the three main hardware components of a client/server

More information

Ark Database Documentation

Ark Database Documentation Ark Database Documentation Release 0.1.0 Liu Dong Nov 24, 2017 Contents 1 Introduction 3 1.1 What s included............................................. 3 1.2 Supported Drivers............................................

More information

Database Systems Fundamentals

Database Systems Fundamentals Database Systems Fundamentals Using PHP Language Arman Malekzade Amirkabir University of Technology (Tehran Polytechnic) Notice: The class is held under the supervision of Dr.Shiri github.com/arman-malekzade

More information

If you do not specify any custom parameters, we will deliver the message using the default names.

If you do not specify any custom parameters, we will deliver the message using the default names. Inbound SMS to UK landline numbers API HTTP GET/POST variables If you choose to have the messages delivered by HTTP, you may either use our standard parameters, or create a custom format for compatibility

More information

Form Processing in PHP

Form Processing in PHP Form Processing in PHP Forms Forms are special components which allow your site visitors to supply various information on the HTML page. We have previously talked about creating HTML forms. Forms typically

More information

Monetra. POST Protocol Specification

Monetra. POST Protocol Specification Monetra POST Protocol Specification Programmer's Addendum v1.0 Updated November 2012 Copyright Main Street Softworks, Inc. The information contained herein is provided As Is without warranty of any kind,

More information

Daniel Pittman October 17, 2011

Daniel Pittman October 17, 2011 Daniel Pittman October 17, 2011 SELECT target-list FROM relation-list WHERE qualification target-list A list of attributes of relations in relation-list relation-list A list of relation names qualification

More information

COMP 430 Intro. to Database Systems. Encapsulating SQL code

COMP 430 Intro. to Database Systems. Encapsulating SQL code COMP 430 Intro. to Database Systems Encapsulating SQL code Want to bundle SQL into code blocks Like in every other language Encapsulation Abstraction Code reuse Maintenance DB- or application-level? DB:

More information

IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population

IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population In this lab, your objective is to learn the basics of creating and managing a DB system. One way to interact with the DBMS (MySQL)

More information

1) Introduction to SQL

1) Introduction to SQL 1) Introduction to SQL a) Database language enables users to: i) Create the database and relation structure; ii) Perform insertion, modification and deletion of data from the relationship; and iii) Perform

More information

How to use SQL to create a database

How to use SQL to create a database Chapter 17 How to use SQL to create a database How to create a database CREATE DATABASE my_guitar_shop2; How to create a database only if it does not exist CREATE DATABASE IF NOT EXISTS my_guitar_shop2;

More information

Web accessible Databases PHP

Web accessible Databases PHP Web accessible Databases PHP October 16, 2017 www.php.net Pacific University 1 HTML Primer https://www.w3schools.com/html/default.asp HOME Introduction Basic Tables Lists https://developer.mozilla.org/en-

More information

Mysql interview questions and answers

Mysql interview questions and answers For freshers and experienced Mysql interview questions and answers Content Ref :pcds.co.in only for use Education and Job purpose, not for official purpose. : 1 Answers :1 how to do login in mysql with

More information

Member registration and searching(2)

Member registration and searching(2) Member registration and searching(2) Initial screen for member registration ( ex11-9.php ) 간단한회원등록및검색서비스 간단한회원등록및검색서비스

More information

Using htmlarea & a Database to Maintain Content on a Website

Using htmlarea & a Database to Maintain Content on a Website Using htmlarea & a Database to Maintain Content on a Website by Peter Lavin December 30, 2003 Overview If you wish to develop a website that others can contribute to one option is to have text files sent

More information

Running SQL in Java and PHP

Running SQL in Java and PHP Running SQL in Java and PHP FCDB 9.6 9.7 Dr. Chris Mayfield Department of Computer Science James Madison University Mar 01, 2017 Introduction to JDBC JDBC = Java Database Connectivity 1. Connect to the

More information

CSC 215 PROJECT 2 DR. GODFREY C. MUGANDA

CSC 215 PROJECT 2 DR. GODFREY C. MUGANDA CSC 215 PROJECT 2 DR. GODFREY C. MUGANDA 1. Project Overview In this project, you will create a PHP web application that you can use to track your friends. Along with personal information, the application

More information

Structure Query Language (SQL)

Structure Query Language (SQL) Structure Query Language (SQL) 1 Example to Select all Records from Table A special character asterisk * is used to address all the data(belonging to all columns) in a query. SELECT statement uses * character

More information

Lecture 6 Sorting and Searching

Lecture 6 Sorting and Searching Lecture 6 Sorting and Searching Sorting takes an unordered collection and makes it an ordered one. 1 2 3 4 5 6 77 42 35 12 101 5 1 2 3 4 5 6 5 12 35 42 77 101 There are many algorithms for sorting a list

More information

CHAPTER 10. Connecting to Databases within PHP

CHAPTER 10. Connecting to Databases within PHP CHAPTER 10 Connecting to Databases within PHP CHAPTER OBJECTIVES Get a connection to a MySQL database from within PHP Use a particular database Send a query to the database Parse the query results Check

More information

Required Materials - SQL Server Management Studio - Your copy of the Northwind database

Required Materials - SQL Server Management Studio - Your copy of the Northwind database Analyzing and Optimizing Queries Objective After completing this lab, you will be able to: Analyze the performance of queries using text-based and graphical analysis tools. Perform some common optimizations

More information

By the end of this chapter, you will have a very basic, but fully functional blogging system.

By the end of this chapter, you will have a very basic, but fully functional blogging system. C H A P T E R 5 Building the Entry Manager At this point, you know enough to start building your blog! In this chapter, I ll walk you through how to build the backbone of your blogging application. The

More information

COSC344 Database Theory and Applications PHP & SQL. Lecture 14

COSC344 Database Theory and Applications PHP & SQL. Lecture 14 COSC344 Database Theory and Applications Lecture 14: PHP & SQL COSC344 Lecture 14 1 Last Lecture Java & SQL Overview This Lecture PHP & SQL Revision of the first half of the lectures Source: Lecture notes,

More information

Download and Installation Instructions: After WAMP Server download start the installation:

Download and Installation Instructions: After WAMP Server download start the installation: SET UP Instruction to Set Up a WAMP SERVER with MySQL and to Create a Database in My SQL and Connect from your PHP Script Download WAMP Server V 3.0 or higher from: https://sourceforge.net/projects/wampserver/

More information

School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University

School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University ITS331 Information Technology Laboratory I Laboratory #8: PHP & Form Processing II Objective:

More information

PHP. M hiwa ahamad aziz Raparin univercity. 1 Web Design: Lecturer ( m hiwa ahmad aziz)

PHP. M hiwa ahamad aziz  Raparin univercity. 1 Web Design: Lecturer ( m hiwa ahmad aziz) PHP M hiwa ahamad aziz www.raparinweb.com Raparin univercity 1 Server-Side Programming language asp, asp.net, php, jsp, perl, cgi... 2 Of 68 Client-Side Scripting versus Server-Side Scripting Client-side

More information

Networks and Web for Health Informatics (HINF 6220)

Networks and Web for Health Informatics (HINF 6220) Networks and Web for Health Informatics (HINF 6220) Tutorial #1 Raheleh Makki Email: niri@cs.dal.ca Tutorial Class Timings Tuesday & Thursday 4:05 5:25 PM Course Outline Database Web Programming SQL PHP

More information

More loops. Control structures / flow control. while loops. Loops / Iteration / doing things over and over and over and over...

More loops. Control structures / flow control. while loops. Loops / Iteration / doing things over and over and over and over... Control structures / flow control More loops while loops if... else Switch for loops while... do.. do... while... Much of this material is explained in PHP programming 2nd Ed. Chap 2 Control structures

More information

1. Given the name of a movie studio, find the net worth of its president.

1. Given the name of a movie studio, find the net worth of its president. 1. Given the name of a movie studio, find the net worth of its president. CREATE FUNCTION GetNetWorth( studio VARCHAR(30) ) RETURNS DECIMAL(9,3) DECLARE worth DECIMAL(9,3); SELECT networth INTO worth FROM

More information

30. Structured Query Language (SQL)

30. Structured Query Language (SQL) 30. Structured Query Language (SQL) Java Fall 2009 Instructor: Dr. Masoud Yaghini Outline SQL query keywords Basic SELECT Query WHERE Clause ORDER BY Clause INNER JOIN Clause INSERT Statement UPDATE Statement

More information

Basic PHP. Lecture 19. Robb T. Koether. Hampden-Sydney College. Mon, Feb 26, 2108

Basic PHP. Lecture 19. Robb T. Koether. Hampden-Sydney College. Mon, Feb 26, 2108 Basic PHP Lecture 19 Robb T. Koether Hampden-Sydney College Mon, Feb 26, 2108 Robb T. Koether (Hampden-Sydney College) Basic PHP Mon, Feb 26, 2108 1 / 27 1 PHP 2 The echo Statement 3 Variables 4 Operators

More information

COMP284 Scripting Languages Lecture 13: PHP (Part 5) Handouts

COMP284 Scripting Languages Lecture 13: PHP (Part 5) Handouts COMP284 Scripting Languages Lecture 13: PHP (Part 5) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool

More information

ゼミ Wiki の再構築について 資料編 加納さおり

ゼミ Wiki の再構築について 資料編 加納さおり Wiki [ Fukuda Semi Wiki] [ 2 wiki] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 Menu1] [ 15 Menu2] [ 16 Menu3] [ 17 wiki Menu] [ 18 TOP ] [ 19 ] [ 20 ] [ 20] [ 21 ] [ 22 (

More information

UNIT V ESTABLISHING A DATABASE CONNECTION AND WORKING WITH DATABASE

UNIT V ESTABLISHING A DATABASE CONNECTION AND WORKING WITH DATABASE UNIT V 1 ESTABLISHING A DATABASE CONNECTION AND WORKING WITH DATABASE SYLLABUS 5.1 Overview of Database 5.2 Introduction to MYSQL 5.3 Creating Database using phpmyadmin & Console(using query, using Wamp

More information

ITS331 IT Laboratory I: (Laboratory #11) Session Handling

ITS331 IT Laboratory I: (Laboratory #11) Session Handling School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University ITS331 Information Technology Laboratory I Laboratory #11: Session Handling Creating

More information

Chapter 15 Java Server Pages (JSP)

Chapter 15 Java Server Pages (JSP) Sungkyunkwan University Chapter 15 Java Server Pages (JSP) Prepared by J. Jung and H. Choo Web Programming Copyright 2000-2018 Networking 2000-2012 Networking Laboratory Laboratory 1/30 Server & Client

More information

A QUICK GUIDE TO PROGRAMMING FOR THE WEB. ssh (then type your UBIT password when prompted)

A QUICK GUIDE TO PROGRAMMING FOR THE WEB. ssh (then type your UBIT password when prompted) A QUICK GUIDE TO PROGRAMMING FOR THE WEB TO GET ACCESS TO THE SERVER: ssh Secure- Shell. A command- line program that allows you to log in to a server and access your files there as you would on your own

More information

Create Basic Databases and Integrate with a Website Lesson 5

Create Basic Databases and Integrate with a Website Lesson 5 Create Basic Databases and Integrate with a Website Lesson 5 Forum Project In this lesson we will be creating a simple discussion forum which will be running from your domain. If you wish you can develop

More information

Week 11 ~ Chapter 8 MySQL Command Line. PHP and MySQL CIS 86 Mission College

Week 11 ~ Chapter 8 MySQL Command Line. PHP and MySQL CIS 86 Mission College Week 11 ~ Chapter 8 MySQL Command Line PHP and MySQL CIS 86 Mission College Tonight s agenda Drop the class? Why learn MySQL command line? Logging on to the Mission College MySQL server Basic MySQL commands

More information

PHP 5 if...else...elseif Statements

PHP 5 if...else...elseif Statements PHP 5 if...else...elseif Statements Conditional statements are used to perform different actions based on different conditions. PHP Conditional Statements Very often when you write code, you want to perform

More information