Oleh: Rony Syahputra Nasution | Oktober 24, 2009

Ajax, PHP, MySQL dan Combobox (HTML)

Menindak lanjuti,
pengenalan singkat Ajax terdahulu,
berikut saya hadirkan hehehe,
contoh kasus yang melibatkan,
Ajax, PHP, MySQL dan komponen combo box dari HTML.

Langkah awal,
adalah membuat database pada MySQL.

Beri nama database,
dengan nama “ajax” (tanpa tanda petik).

Kemudian,
buat 2 buat tabel,
tabel departments dan employees

tabel departments :
CREATE TABLE IF NOT EXISTS `departments` (
  `department_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
  `department` varchar(30) NOT NULL,
  PRIMARY KEY (`department_id`),
  UNIQUE KEY `department` (`department`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

tabel employees :
CREATE TABLE IF NOT EXISTS `employees` (
  `employee_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `department_id` tinyint(3) unsigned NOT NULL,
  `first_name` varchar(20) NOT NULL,
  `last_name` varchar(40) NOT NULL,
  `email` varchar(60) NOT NULL,
  `phone_ext` smallint(5) unsigned NOT NULL,
  PRIMARY KEY (`employee_id`),
  UNIQUE KEY `email` (`email`),
  KEY `department_id` (`department_id`),
  KEY `last_name` (`last_name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 
Selanjutnya,
adalah proses entry data,
pada kedua tabel tersebut.

Data tabel departments :
INSERT INTO `departments` (`department_id`, `department`) VALUES
(1, ‘Human Resources’),
(2, ‘Accounting’),
(3, ‘Marketing’),
(4, ‘Redundancy Department’);

Data tabel employees :
INSERT INTO `employees` (`employee_id`, `department_id`, `first_name`, `last_name`, `email`, `phone_ext`) VALUES
(1, 1, ‘Laila’, ‘Smith’, ‘l.smith@thiscompany.com’, 234),
(2, 1, ‘Laverne’, ‘Green’, ‘l.green@thiscompany.com’, 235),
(3, 1, ‘Cal’, ‘Perez’, ‘c.perez@thiscompany.com’, 230),
(4, 1, ‘Brian’, ‘Rogers’, ‘brianr@thiscompany.com’, 231),
(5, 1, ‘Carla’, ‘Cox’, ‘cc@thiscompany.com’, 233),
(6, 2, ‘Ezra’, ‘Howard’, ‘e.howard@thiscompany.com’, 122),
(7, 2, ‘Gideon’, ‘Gray’, ‘g.gray@thiscompany.com’, 128),
(8, 2, ‘Penelope’, ‘Brooks’, ‘pb@thiscompany.com’, 129),
(9, 2, ‘Olive’, ‘Kelly’, ‘olive@thiscompany.com’, 120),
(10, 2, ‘Justine’, ‘Sanders’, ‘j.sanders@thiscompany.com’, 123),
(11, 2, ‘Zoe’, ‘Ford’, ‘zoe@thiscompany.com’, 125),
(12, 3, ‘Sam’, ‘Fisher’, ‘sam@thiscompany.com’, 385),
(13, 3, ‘Henry’, ‘Barnes’, ‘henry@thiscompany.com’, 386),
(14, 3, ‘Eleanor’, ‘Wood’, ‘eleanor@thiscompany.com’, 387),
(15, 4, ‘Emmet’, ‘Humphries’, ‘e.humphries@thiscompany.com’, 401),
(16, 4, ‘Conrad’, ‘Madsen’, ‘conrad@thiscompany.com’, 410),
(17, 4, ‘Maude’, ‘Ernst’, ‘m.ernst@thiscompany.com’, 409),
(18, 4, ‘Stella’, ‘Redding’, ‘s.redding@thiscompany.com’, 408),
(19, 4, ‘Nat’, ‘Fugate’, ‘nat@thiscompany.com’, 407),
(20, 4, ‘Hazel’, ‘Hay’, ‘h.hay@thiscompany.com’, 402);

Sampai sini,
anda sudah memiliki,
data yang akan diproses dengan konsep Ajax bersama php.

Untuk memudahkan,
anda dapat memiliki file SQL dari perintah diatas,
disini.

Bagaimana ?
mudahkan ^_^,
untuk proses selanjutnya,
akan kita bahas pada kesempatan kedepan.

Semoga bermanfaat.

Salam dari Cirebon,
Rony Syahputra Nasution.


Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

Kategori

%d blogger menyukai ini: