Skip to main content

PHP–Projek ROSES

1. config.php

<?php
//database configuration info
$db=mysqli_connect("localhost","root","abc123","roses");
if($db==false){
echo "DB connect error: ";
echo mysqli_connect_error($db);
}else{
//echo "Database connected";
}

?>


 


2: senarairekod.php


image



<?php
//paparan semua rekod
include "config.php";
?>
<html>
<head>
<title>Roses: Laporan</title>
</head>
<body>
Senarai semua rekod dalam jadual Daftar<br>
<?php
//sql command to fectch all records
$sql="SELECT id , namapertubuhan , alamat ,
poskod , negeri FROM daftar"
;
//send sql command to db server
$rs=mysqli_query($db, $sql);
//display sql error
if($rs==false){
echo mysqli_error($db);
}
//identify number of records
$bilrekod=mysqli_num_rows($rs);
if($bilrekod==0){
echo "Tiada rekod diperolehi";
}
else{//rekod ada, boleh papar
?>
<table width="90%" border="1">
<tr align="center">
<td>id</td>
<td>Nama pertubuhan</td>
<td>Alamat</td>
<td>Poskod</td>
<td>Negeri</td>
</tr>
<?php
while($rekod=mysqli_fetch_array($rs)){
?>
<tr>
<td><?=$rekod['id']?></td>
<td><?=$rekod['namapertubuhan']?></td>
<td><?=$rekod['alamat']?></td>
<td><?=$rekod['poskod']?></td>
<td><?=$rekod['negeri']?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
</body>
</html>





3. carian.php


image


<?php
//paparan semua rekod
include "config.php";
?>
<html>
<head>
<title>Roses: Carian</title>
</head>
<body>
Cari nama Pertubuhan<br>

<form action="" method="get" name="formsearch">
Enter a name <input name="txtsearch" type="text">
<input name="btnsearch" type="submit" value="Cari">
</form>
<?php
$carian=$_GET['txtsearch'];
echo "Carian untuk: $carian <br>";
//sql command to fetch all records
$sql="SELECT id , namapertubuhan , alamat ,
poskod , negeri FROM daftar
WHERE namapertubuhan LIKE '%$carian%' "
;
//send sql command to db server
$rs=mysqli_query($db, $sql);
//display sql error
if($rs==false){
echo mysqli_error($db);
}
//identify number of records
$bilrekod=mysqli_num_rows($rs);
if($bilrekod==0){
echo "Tiada rekod diperolehi";
}
else{//rekod ada, boleh papar
?>
<table width="90%" border="1">
<tr align="center">
<td>id</td>
<td>Nama pertubuhan</td>
<td>Alamat</td>
<td>Poskod</td>
<td>Negeri</td>
</tr>
<?php
while($rekod=mysqli_fetch_array($rs)){
?>
<tr>
<td><?=$rekod['id']?></td>
<td><?=$rekod['namapertubuhan']?></td>
<td><?=$rekod['alamat']?></td>
<td><?=$rekod['poskod']?></td>
<td><?=$rekod['negeri']?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
</body>
</html>





4. carian-nama-tahun.php


image


<?php
//paparan semua rekod
include "config.php";
?>
<html>
<head>
<title>Roses: Carian</title>
</head>
<body>
Cari nama Pertubuhan<br>

<form action="" method="get" name="formsearch">
Nama pertubuhan <input name="txtsearch" type="text"
value="<?php echo $_GET['txtsearch'] ?>">
Tahun didaftar <input name="txttahun" type="text"
value="<?php echo $_GET['txttahun'] ?>"
maxlength=4>
<input name="btnsearch" type="submit" value="Cari">
</form>
<?php
$carian=$_GET['txtsearch'];
$tahun=$_GET['txttahun'];
echo "Carian untuk pertubuhan: $carian <br>";
echo "Tahun didaftar: $tahun <br>";
//sql command to fetch all records
$sql="SELECT id , namapertubuhan , alamat ,
poskod , negeri, masadaftar FROM daftar
WHERE namapertubuhan LIKE '%$carian%'
AND year(masadaftar)='$tahun'"
;
//send sql command to db server
$rs=mysqli_query($db, $sql);
//display sql error
if($rs==false){
echo mysqli_error($db);
}
//identify number of records
$bilrekod=mysqli_num_rows($rs);
if($bilrekod==0){
echo "Tiada rekod diperolehi";
}
else{//rekod ada, boleh papar
?>
<table width="90%" border="1">
<tr align="center">
<td>id</td>
<td>Nama pertubuhan</td>
<td>Alamat</td>
<td>Poskod</td>
<td>Negeri</td>
<td>Tarikh daftar</td>
</tr>
<?php
while($rekod=mysqli_fetch_array($rs)){
?>
<tr>
<td><?=$rekod['id']?></td>
<td><?=$rekod['namapertubuhan']?></td>
<td><?=$rekod['alamat']?></td>
<td><?=$rekod['poskod']?></td>
<td><?=$rekod['negeri']?></td>
<td><?=$rekod['masadaftar']?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
</body>
</html>




 

 

5. insert.php

 

image

<?php
//paparan semua rekod
include "config.php";
?>
<html>
<head>
<title>Roses: Masuk rekod baru</title>
</head>
<body>
Cari nama Pertubuhan<br>

<form action="" method="get" name="forminsert">
Nama pertubuhan <input name="txtnama" type="text"><br>
Alamat <input name="txtalamat" type="text"><br>
Poskod <input name="txtposkod" type="text" maxlength=5><br>
Negeri
<select name="txtnegeri">
<?php
$rsn=mysqli_query($db, "SELECT * FROM negeri");
while($recn=mysqli_fetch_array($rsn)){
echo "<option value=".$recn['kodnegeri'].">".
$recn['keterangan']."</option>";
}
?>
</select>
<br>
No Telefon <input name="txttelefon" type="text"><br>
Emel <input name="txtemel" type="text"><br>
Nama Setiausaha <input name="txtnamasu" type="text"><br>
No KP Setiausaha <input name="txticsu" type="text"><br>

<input name="btninsert" type="submit" value="Simpan">
</form>
<?php
$nama=$_GET["txtnama"];
$alamat=$_GET["txtalamat"];
$poskod=$_GET["txtposkod"];
$negeri=$_GET["txtnegeri"];
$telefon=$_GET["txttelefon"];
$emel=$_GET["txtemel"];
$namasu=$_GET["txtnamasu"];
$icsu=$_GET["txticsu"];
if ($nama!=null){//pastikan user dah masukkan data
//sql utk masukkan rekod baru dlm db
$sql="INSERT INTO daftar
values
('','$nama','$alamat','$poskod','$negeri',
'$telefon','$emel','$namasu','$icsu','')"
;
$rs=mysqli_query($db, $sql);
if($rs==false){
echo "Error in sql:".mysqli_error($db);
echo "Full sql: $sql";
}else{
echo "Nama pertubuhan: $nama<br>";
echo "Alamat: $alamat, $poskod, $negeri<br>";
echo "Rekod berjaya disimpan<br>";
}
}//if not null
?>
</body>
</html>





6. listedit.php

 

image

<?php
//paparan semua rekod
include "config.php";
?>
<html>
<head>
<title>Roses: Senarai utk Edit</title>
</head>
<body>
Cari nama Pertubuhan<br>

<form action="" method="get" name="formsearch">
Enter a name <input name="txtsearch" type="text">
<input name="btnsearch" type="submit" value="Cari">
</form>
<?php
$carian=$_GET['txtsearch'];
echo "Carian untuk: $carian <br>";
//sql command to fetch all records
$sql="SELECT id , namapertubuhan , alamat ,
poskod , negeri FROM daftar
WHERE namapertubuhan LIKE '%$carian%' "
;
//send sql command to db server
$rs=mysqli_query($db, $sql);
//display sql error
if($rs==false){
echo mysqli_error($db);
}
//identify number of records
$bilrekod=mysqli_num_rows($rs);
if($bilrekod==0){
echo "Tiada rekod diperolehi";
}
else{//rekod ada, boleh papar
?>
<table width="90%" border="1">
<tr align="center">
<td> </td>
<td>id</td>
<td>Nama pertubuhan</td>
<td>Alamat</td>
<td>Poskod</td>
<td>Negeri</td>
</tr>
<?php
while($rekod=mysqli_fetch_array($rs)){
$id=$rekod['id'];
?>
<tr>
<td><a href="edit.php?id=<?php echo $id?>">
edit</a></td>
<td><a href="hapus.php?id=<?php echo $id?>">
hapus</a></td>
<td><?php echo $rekod['id']?></td>
<td><?php echo $rekod['namapertubuhan']?></td>
<td><?php echo $rekod['alamat']?></td>
<td><?php echo $rekod['poskod']?></td>
<td><?php echo $rekod['negeri']?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
</body>
</html>




 

 

7. edit.php

image


<?php
//paparan semua rekod
include "config.php";
$id=$_GET['id'];
$sqle="SELECT * FROM daftar WHERE id='$id'";
$rse=mysqli_query($db, $sqle);
$re=mysqli_fetch_array($rse);
$nama=$re['namapertubuhan'];
$alamat=$re['alamat'];
$poskod=$re['poskod'];
$negeri=$re['negeri'];
$telefon=$re['telefon'];
$email=$re['email'];
$namasu=$re['namasu'];
$icsu=$re['icsu'];
?>
<html>
<head>
<title>Roses: Edit rekod lama</title>
</head>
<body>
Edit Pertubuhan<br>

<form action="simpan.php" method="get" name="forminsert">
ID <input name="txtid" type="text"
value="<?php echo $id ?>"><br>
Nama pertubuhan <input name="txtnama" type="text"
value="<?php echo $nama ?>"><br>
Alamat <input name="txtalamat" type="text"
value="<?php echo $alamat ?>"><br>
Poskod <input name="txtposkod" type="text" maxlength=5
value="<?php echo $poskod ?>"><br>
Negeri <?php echo $negeri ?>
<select name="txtnegeri">
<?php
$rsn=mysqli_query($db, "SELECT * FROM negeri");
while($recn=mysqli_fetch_array($rsn)){
if($recn['kodnegeri']==$negeri){
echo "<option value=".$recn['kodnegeri']." selected >".
$recn['keterangan']."</option>\n";
}else{
echo "<option value=".$recn['kodnegeri']." >".
$recn['keterangan']."</option>\n";
}
}
?>
</select>
<br>
No Telefon <input name="txttelefon" type="text"
value="<?php echo $telefon ?>"><br>
Emel <input name="txtemel" type="text"
value="<?php echo $email ?>"><br>
Nama Setiausaha <input name="txtnamasu" type="text"
value="<?php echo $namasu ?>"><br>
No KP Setiausaha <input name="txticsu" type="text"
value="<?php echo $icsu ?>"><br>

<input name="btninsert" type="submit" value="Simpan">
</form>

</body>
</html>







0. Database


-- phpMyAdmin SQL Dump
-- version 2.11.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Oct 13, 2011 at 03:58 AM
-- Server version: 5.0.45
-- PHP Version: 5.2.4

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `roses`
--
CREATE DATABASE `roses` DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci;
USE `roses`;

-- --------------------------------------------------------

--
-- Table structure for table `daftar`
--
CREATE TABLE `daftar` (
`id` int(11) NOT NULL auto_increment,
`namapertubuhan` varchar(100) collate latin1_general_ci NOT NULL,
`alamat` varchar(100) collate latin1_general_ci NOT NULL,
`poskod` varchar(5) collate latin1_general_ci NOT NULL,
`negeri` varchar(2) collate latin1_general_ci NOT NULL,
`telefon` varchar(15) collate latin1_general_ci NOT NULL,
`email` varchar(100) collate latin1_general_ci NOT NULL,
`namasu` varchar(100) collate latin1_general_ci NOT NULL,
`icsu` varchar(14) collate latin1_general_ci NOT NULL,
`masadaftar` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=11 ;

--
-- Dumping data for table `daftar`
--
INSERT INTO `daftar` (`id`, `namapertubuhan`, `alamat`, `poskod`, `negeri`, `telefon`, `email`, `namasu`, `icsu`, `masadaftar`) VALUES
(1, 'Persatuan Kerabat Abd Rahman', 'Parit Sulong, Batu Pahat', '83500', '01', '0129034614', 'khirulnizam@gmail.com', 'Khirulnizam Abd Rahman', '760818017303', '2011-10-12 10:39:14'),
(2, 'Persatuan Pembangun Laman Web', 'Bangi', '43600', '10', '0389254251', 'webdev@gmail.com', 'Ali Mamat', '770801032872', '2011-10-12 10:39:14'),
(3, 'Rumah Amal Nilai', 'Taman Semarak, Nilai', '71700', '05', '0172131234', 'amalnilai@gmail.com', 'Faridah Ali', '870102142341', '2011-10-12 10:40:58'),
(10, 'Pertubuhan Web Se-Malaysia', 'Parit Jawa, Muar', '83000', '01', '', '', '', '', '2011-10-12 16:46:45');

-- --------------------------------------------------------

--
-- Table structure for table `negeri`
--
CREATE TABLE `negeri` (
`kodnegeri` varchar(2) collate latin1_general_ci NOT NULL,
`keterangan` varchar(50) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`kodnegeri`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

--
-- Dumping data for table `negeri`
--
INSERT INTO `negeri` (`kodnegeri`, `keterangan`) VALUES
('01', 'Johor'),
('02', 'Kedah'),
('03', 'Kelantan'),
('04', 'Melaka'),
('05', 'Negeri Sembilan'),
('06', 'Pahang'),
('07', 'Pulau Pinang'),
('08', 'Perak'),
('09', 'Perlis'),
('10', 'Selangor'),
('11', 'Terengganu'),
('12', 'Sabah'),
('13', 'Sarawak'),
('14', 'Wilayah Persekutuan (Kuala Lumpur)'),
('15', 'Wilayah Persekutuan (Labuan)'),
('16', 'Wilayah Persekutuan (Putrajaya)');


 

Comments

Popular posts from this blog

Several English proverbs and the Malay pair

Or you could download here for the Malay proverbs app – https://play.google.com/store/apps/details?id=net.kerul.peribahasa English proverbs and the Malay pair Corpus Reference: Amir Muslim, 2009. Peribahasa dan ungkapan Inggeris-Melayu. DBP, Kuala Lumpur http://books.google.com.my/books/about/Peribahasa_dan_ungkapan_Inggeris_Melayu.html?id=bgwwQwAACAAJ CTRL+F to search Proverbs in English Definition in English Similar Malay Proverbs Definition in Malay 1 Where there is a country, there are people. A country must have people. Ada air adalah ikan. Ada negeri adalah rakyatnya. 2 Dry bread at home is better than roast meat home's the best hujan emas di negeri orang,hujan batu di negeri sendiri Betapa baik pun tempat orang, baik lagi tempat sendiri. 3 There's no accounting for tastes We can't assume that every people have a same feel Kepala sama hitam hati lain-lain. Dalam kehidupan ini, setiap insan berbeza cara, kesukaan, perangai, tabia

Contact Us at blog.kerul.net

Powered by EMF HTML Contact Form

Login JSON Android using Login Activity

I’ve been trying to release this tutorial quite a while. At last after a long hard effort. Since HttpClient is not supported any more in Android SDK 23, I have to resort to org.json.JSONObject and java.net.HttpURLConnection library to do online database with JSON. The objective of this tutorial is to log-in from a mobile client with the username and password stored in an online database facility. STEP 1: Create a new Android project, this time choose the LoginActivity .

Bootstrap Template for PHP database system - MyCompanyHR

HTML without framework is dull. Doing hard-coded CSS and JS are quite difficult with no promising result on cross platform compatibility. So I decided to explore BootStrap as they said it is the most popular web framework. What is BootStrap? - Bootstrap is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first web sites. (  http://www.w3schools.com/bootstrap/   ) Available here -  http://getbootstrap.com/ Why you need Flat-UI? Seems like a beautiful theme to make my site look professional. Anyway you could get variety of BootStrap theme out there, feel free to select here  http://bootstraphero.com/the-big-badass-list-of-twitter-bootstrap-resources/ Flat-UI is from DesignModo -   http://designmodo.com/flat/ Web Programming MyCompanyHR – PHP & MySQL mini project (with Boostrap HTML framework) Template 1: Template for the Lab Exercise. This is a project sample of a staff record management system. It has the PHP structured co

Pick a file using Intent.ACTION_GET_CONTENT

This tutorial is tested on Honeycomb 3.0 environment. In order to be used it in the lower level of Android API, I believe you could just change the target in the Android project. Screenshots Pick an image file using Intent.ACTION_GET_CONTENT The intention of this project is to choose an image file available in the device storage, and simply display it in an ImageView. The benefit of using Intent.ACTION_GET_CONTENT is you don’t have to develop open dialog box which is not available in the Android library. ACTION_GET_CONTENT with MIME type */* and category CATEGORY_OPENABLE -- Display all pickers for data that can be opened with ContentResolver.openInputStream() , allowing the user to pick one of them and then some data inside of it and returning the resulting URI to the caller. This can be used, for example, image chooser (as shown in this article).