SlideShare a Scribd company logo
1 of 24
PHP FATIMAH SENONG PELATIH UUM_KYM 09
APA ITU PHP ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SYNTAX PHP ,[object Object],[object Object],<?php ?> <html><body> <?php echo “Hello world”; ?> </body></html> Echo = print berfungsi untuk mempamerkan apa yang dikehendaki
PEMBOLEHUBAH PHP ,[object Object],[object Object],[object Object],[object Object],$VariableName $my name = X $myName = √ $my_name = √ <?php $txt = “Hello world”; $number = 16; echo $txt . “”. $number; ?> Hello world 16 Hasilnya
If….else ,[object Object],[object Object],[object Object],[object Object],If(syarat) { Penyataan 1 } else(syarat) { Penyataan 2 } 1) Syarat akan dipriksa 2) Bila nilai true, maka penyataan 1 dijalankan. 3) Bila nilai false, penyataan 2 dijalankan . penerangan <?php $a=4; $b=9; If($a>$b) { echo(“a lebih besar dari pada b”); } elseif ($a<$b) { echo(“a lebih kecil b”); } else { echo(“a sama dengan b”); } ?>
while ,[object Object],[object Object],[object Object],While(syarat) { Penyataan } <?php $a=1; while ($a<10) { echo($a); $a++; } ?> Hasilnya
for ,[object Object],[object Object],for (ekspresi1; ekspresi2 ; ekspresi3) { Statement } 1) ekspresi1 menunjukkan nilai awal  untuk suatu variable 2) ekspresi2 menunjukkan syarat  yang harus terpenuhi untuk  menjalankan statemant 3) ekspresi3 menunjukkan  pertambahan nilai untuk suatu  variable penerangan <?php for ($a=0;$a<10;$a++) { echo(“Nilai A = ”); echo(“$a”); echo(“<br>”); } ?> Hasilnya
require ,[object Object],[object Object],[object Object],require(filename) <?php $a=”Saya sedang belajar PHP”; function tulistebal($teks) { echo(“<b>$teks</b>”); } ?> Contoh9.php <?php require(“contoh9.php”); tulistebal(“Ini adalah tulisan tebal”); echo(“<br>”); echo($a); ?> Contoh10.php berkaitan Hasilnya
include ,[object Object],[object Object],[object Object],<?php echo(“--------------------------------------<br>”); echo(“PHP adalah bahasa scripting<br>”); echo(“--------------------------------------<br>”); echo(“<br>”); ?> Contoh11.php <?php for ($b=1; $b<5; $b++) { include(“contoh11.php”); } ?> Contoh12.php berkaitan Hasilnya
Menbuat Database ,[object Object],[object Object],[object Object],[object Object],[object Object],Muka depan ini, boleh lah membina nama Db di ruang yang disediakan
Samb.. ,[object Object],[object Object],[object Object],[object Object]
Access MySQL dr PHP   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],$connection = mysql_connect(“localhost”,”root”,””); $selection = mysql_select_db(“namaDB”);
[object Object],[object Object],[object Object],[object Object],[object Object],$sql=&quot; SELECT * from tableDB&quot;; $result=mysql_query($sql)or die(&quot;SQL select statement failed&quot;); $sql =  “INSERT INTO tableDB(nama column) VALUES (isi column)”; $result = mysql_query($sql); If($result)…. $sql = &quot; DELETE FROM tableDB &quot;; $result = mysql_query($sql); $sql = “ UPDATE tableDB SET <nama column>=<isi column> WHERE….”; $result = mysql_query($sql);
INSERT INTO ,[object Object],<html> <head> <title>Belajar Php</title> </head> <form method=&quot;post&quot; action=&quot;add.php&quot;> <body> Tentang Saya Nama:  <input type=&quot;text&quot; name=&quot;Nama&quot; size=&quot;40&quot;> Umur : <input type=&quot;text&quot; name=“Umur&quot; size=&quot;40&quot;> Jawatan : <input type=&quot;text&quot; name=&quot;Nama&quot; size=&quot;40&quot;> <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Hantar&quot;> <input name=&quot;reset&quot; type = &quot;reset&quot; Value = &quot;Batal&quot;> </body></html> add.html Hasilnya
Samb.. ,[object Object],<?php $Nama=$_POST[&quot;Nama&quot;]; $Umur=$_POST[&quot;Umur&quot;]; $Jawatan=$_POST[&quot;Jawatan&quot;]; $connection=mysql_connect(&quot;localhost&quot;,&quot;root&quot;,&quot;&quot;) or die (&quot;Could not connect to MySQL&quot;.mysql_error()); $selection=mysql_select_db(&quot;php&quot;) or die(&quot;Unable to select database.&quot;.mysql_error()); $sql=&quot;INSERT INTO belajar(Nama,Umur,Jawatan) VALUES('$Nama','$Umur','$Jawatan')&quot;; $result=mysql_query($sql); if($result){echo &quot;<b>Maklumat telah di Terima</b>&quot;; echo &quot;<p><b>Nama :$Nama</b>&quot;; echo&quot;<p><b>Umur :$Umur</b>&quot;; echo&quot;<p><b>Jawatan :$Jawatan</b>&quot;; } else {die(mysql_error());} ?> add.php
SELECT ,[object Object],<html><head> <title>belajar Php</title> </head><body> <a href=&quot;view.php&quot;>Senarai DB</a> </body><html> view.html Hasilnya
Samb.. ,[object Object],<?php $connection=mysql_connect(&quot;localhost&quot;,&quot;root&quot;,&quot;&quot;) or die(&quot;could not connect to MySQL&quot;.mysql_error()); $selection=mysql_select_db(&quot;php&quot;) or die(&quot;Unable to select database&quot;.mysql_error()); $sql=&quot;SELECT*from belajar&quot;; $result=mysql_query($sql) or die(&quot;SQL select statement failed&quot;); $result=mysql_query($sql); echo&quot;<table align='center' border='1' bgcolor='green'>&quot;; echo &quot;<tr><td>Nama</td><td>Umur</td><td>Jawatan</td></tr>&quot;;   while($row=mysql_fetch_array($result)){ $Nama=$row[&quot;Nama&quot;]; $Umur=$row[&quot;Umur&quot;]; $Jawatan=$row[&quot;Jawatan&quot;]; echo &quot;<tr><td>$Nama</td><td>$Umur</td><td>$Jawatan</td></tr>&quot;;} echo&quot;</table>&quot;; ?> Hasilnya view.php
UPDATE ,[object Object],<html><head><title>Belajar php</title></head> <form method=&quot;post&quot; action=“update.php&quot;> <body> Kemaskini Maklumat Masukkan Nama :  <input type=&quot;text&quot; name=&quot;Nama&quot; size=&quot;40&quot;>  <input type=&quot;submit&quot; name=“submit&quot; value=&quot;Hantar&quot;> <input name=&quot;reset&quot; type = &quot;reset&quot; Value = &quot;Batal&quot;> </body></html> update.html Hasilnya
Samb.. ,[object Object],<form method=&quot;post&quot; action=&quot;update.php&quot;> <?php $connection = mysql_connect(&quot;localhost&quot;,&quot;root&quot;) or die(&quot;Could not connect to MySQL&quot;.mysql_error()); $selection = mysql_select_db(&quot;php&quot;) or die(&quot;Unable to select database.&quot;.mysql_error()); $submit = $_POST[&quot;submit&quot;]; if($submit ==&quot;Hantar&quot;) { if(isset($_POST[&quot;Nama&quot;])) { $Nama = $_POST[&quot;Nama&quot;]; $sql = &quot;SELECT * from belajar where Nama = '$Nama'&quot;; $result = mysql_query($sql) or die(&quot;SQL select statement failed&quot;); $row = mysql_fetch_array($result); echo &quot;Nama : <b>$row[Nama]</b><p>&quot;; echo &quot;Umur :<b>$row[Umur]</b><p>&quot;; echo &quot;Jawatan :<input type='text' name = 'Jawatan' value = '$row[Jawatan]' size = '40'<p>&quot;; echo &quot;<input type = 'hidden' name = 'Nama' value = $row[Nama]><p>&quot;; echo &quot;<input type = 'submit' name = 'submit' value = 'update'>&quot;;  } } if($submit == &quot;update&quot;) {$Nama = $_POST[&quot;Nama&quot;]; $Umur = $_POST[&quot;Umur&quot;]; $Jawatan = $_POST[&quot;Jawatan&quot;]; $sql = &quot;UPDATE belajar SET Jawatan = '$Jawatan'WHERE Nama = '$Nama'&quot;; $result = mysql_query($sql); echo &quot;<hr><h2> Maklumat telah Dikemaskini</h2><p>&quot;; echo &quot;Nama : $Nama <p>&quot;; echo &quot;Umur : <u><b>$Umur</b></u>&quot;; echo &quot;Jawatan : <u><b>$Jawatan</b></u><br>&quot;; } ?> Update.php
Samb.. ,[object Object],Perlu menekan butang update. Agar maklumat dapat dikemaskini dalam DB Ini adalah hasil setelah butang update klik.
DELETE ,[object Object],<html><head><title>Belajar php</title></head> <form method=&quot;post&quot; action=&quot;lupus.php&quot;> <body> PERLUPUSAN MAKLUMAT Masukkan Nama :  <input type=&quot;text&quot; name=&quot;Nama&quot; size=&quot;40&quot;>  <input type=&quot;submit&quot; name=“submit&quot; value=&quot;Hantar&quot;> <input name=&quot;reset&quot; type = &quot;reset&quot; Value = &quot;Batal&quot;> </body></html> lupus.html hasilnya
Samb… ,[object Object],<?php $connection=mysql_connect(&quot;localhost&quot;,&quot;root&quot;,&quot;&quot;) or die(&quot;could not connect to MySQL&quot;.mysql_error()); $selection=mysql_select_db(&quot;php&quot;) or die(&quot;Unable to select database&quot;.mysql_error()); $submit = $_POST[&quot;submit&quot;]; if($submit == &quot;Cari&quot;) { if(isset($_POST[&quot;Nama&quot;])) {$Nama = $_POST[&quot;Nama&quot;]; $sql= &quot;SELECT * FROM belajar where Nama = '$Nama'&quot;; $result = mysql_query($sql) or die (&quot;SQL selsct statement failed&quot;); if($row = mysql_fetch_array($result)) { echo &quot;<b><i>Ini adalah maklumat yang anda ingin lupuskan</i></b><p>&quot;; echo &quot;Nama : <b>$row[Nama]</b><p>&quot;; echo &quot;Umur : <b>$row[Umur]</b><p>&quot;; echo &quot;Jawatan : <b>$row[Jawatan]</b><p>&quot;; echo &quot;<input type = 'hidden' name = 'Nama' value = '$row[Nama]'>&quot;; echo &quot;<input type = 'submit' name = 'submit' value = 'DELETE?'>&quot;;} else { echo &quot;No record found&quot;;} } } if($submit==&quot;DELETE?&quot;) { $Nama = $_POST[&quot;Nama&quot;]; $sql = &quot;DELETE FROM belajar WHERE Nama = $Nama&quot;; $result = mysql_query($sql); echo &quot;<hr><h2> Penghapusan Berjaya</h2><br>&quot;; } ?> </form> lupus.php
Samb… ,[object Object],Butang delete perlu diklik supaya penglupusan dapat dilaksanakan. Penghapusan berjaya tertera apabila butang delete diklik.
Login.. ,[object Object]

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Tutorial Php

  • 1. PHP FATIMAH SENONG PELATIH UUM_KYM 09
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.