|
| Ask Java Script dan PHP | |
|
+4wltr3565 hart reijubv NewJessy 8 posters | Pengirim | Message |
---|
NewJessy Novice
Posts : 223 Thanked : 4 Engine : RMXP Skill : Beginner Type : Artist
| Subyek: Ask Java Script dan PHP 2010-03-21, 17:31 | |
| wah sry kalau buat post melulu kalau pemula emang begitu... oh iya yang bisa script java script dan php post scriptnya di sini semoga berguna bagi kk dan cc | |
| | | reijubv Kai Runes
Posts : 1476 Thanked : 33 Engine : RMVX
Trophies
Awards:
| Subyek: Re: Ask Java Script dan PHP 2010-03-21, 17:47 | |
| wah japa ama pehape . . diluar jangkauan saya nih tapi kayaknya dronetujuh bisa deh main2 ama yg kayak gini ?? | |
| | | NewJessy Novice
Posts : 223 Thanked : 4 Engine : RMXP Skill : Beginner Type : Artist
| Subyek: Re: Ask Java Script dan PHP 2010-03-21, 18:14 | |
| java script agak gampang php wah udah susah panjang lagi! | |
| | | reijubv Kai Runes
Posts : 1476 Thanked : 33 Engine : RMVX
Trophies
Awards:
| Subyek: Re: Ask Java Script dan PHP 2010-03-21, 18:15 | |
| javascript ama java beda kan?
di kampus lagi belajar JAVA, kalo sama mungkin nanti saya bisa bikin javascript juga. .
tapi kalo ngga ya , .
php juga wa kaga ngerti sama sekali , ,
kau bisa ga rekka ? klo bisa post aja di sini | |
| | | hart Senior
Posts : 805 Thanked : 38 Engine : Other Skill : Very Beginner Type : Developer
| Subyek: Re: Ask Java Script dan PHP 2010-03-21, 18:55 | |
| wah, mantap trid ini.. ane mau berbagi.. boleh ga? mau boleh atau nggak, tetap saya post ini tugas saya yang baru lewat, pake PHP, Javascript, 1 baris CSS , dan MySQL: Catatan: nama file harus dibuat persis dengan yang saya tulis supaya bisa bekerja. file DATABASE.sql (ditulis di notepad dulu trus diimpor di PHPMyAdmin atau langsung tulis di code SQL di PHPMyAdmin, terserah) - Spoiler:
- Code:
-
-- phpMyAdmin SQL Dump -- version 2.11.7 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Feb 04, 2010 at 09:22 AM -- Server version: 5.0.51 -- PHP Version: 5.2.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- -- Database: `data_boneka` -- CREATE DATABASE `data_boneka` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; USE `data_boneka`;
-- --------------------------------------------------------
-- -- Table structure for table `tabel_boneka` --
CREATE TABLE IF NOT EXISTS `tabel_boneka` ( `Nama_Boneka` varchar(15) NOT NULL, `Gambar_Boneka` varchar(60) NOT NULL, `Harga` int(8) NOT NULL, `Stock` int(3) NOT NULL, `Jumlah` int(3) NOT NULL, PRIMARY KEY (`Nama_Boneka`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- -- Dumping data for table `tabel_boneka` --
INSERT INTO `tabel_boneka` (`Nama_Boneka`, `Gambar_Boneka`, `Harga`, `Stock`, `Jumlah`) VALUES ('Boneka Lucu', '<img src="/tugas_pemrograman_web/image/image2.jpg" />', 100000, 20, 0), ('Boneka Imut', '<img src="/tugas_pemrograman_web/image/image11.jpg" />', 120000, 12, 0), ('Chubbie Doll', '<img src="/tugas_pemrograman_web/image/image14.jpg" />', 85000, 10, 0), ('Cute Doll', '<img src="/tugas_pemrograman_web/image/image16.jpg" />', 225000, 32, 0), ('Valentine Doll', '<img src="/tugas_pemrograman_web/image/image36.jpg" />', 272500, 5, 0), ('Boneka Cantik', '<img src="/tugas_pemrograman_web/image/image29.jpg" />', 10500, 24, 0);
File desain.css - Spoiler:
- Code:
-
#menu { background: url(image/bg_menu.png); }
File koneksi.php - Spoiler:
- Code:
-
<?php define("NAMA_SERVER", "localhost"); define("PEMAKAI", "root"); define("PASSWORD", ""); define("DATABASE", "data_boneka"); $id_mysql = mysql_connect(NAMA_SERVER, PEMAKAI, PASSWORD); if(!$id_mysql) die("Koneksi ke server gagal!!"); $db_boneka = mysql_select_db(DATABASE, $id_mysql); if(!$db_boneka) die("Koneksi ke server gagal!!"); ?>
file ajax.js - Spoiler:
- Code:
-
var xmlHttp = buatObjekXmlHttp();
function buatObjekXmlHttp() { var obj = null; if (window.ActiveXObject) obj = new ActiveXObject("Microsoft.XMLHTTP"); else if (window.XMLHttpRequest) obj = new XMLHttpRequest(); //Cek isi xmlHttp if (obj == null) document.write("Browser tidak mendukung XMLHttpRequest"); return obj; }
function ambilData(sumber_data, id_elemen) { if (xmlHttp != null) { var obj = document.getElementById(id_elemen); xmlHttp.open("GET", sumber_data); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { obj.innerHTML = xmlHttp.responseText; } } xmlHttp.send(null); } }
file utama.php - Spoiler:
- Code:
-
<html> <head> <title>Doll Evolution Shop</title> <script type="text/javascript" src="ajax.js"> </script> <script type="text/javascript"> function tampilkanBoneka() { var elemen_boneka = document.getElementById("id_boneka"); var nama_boneka = elemen_boneka.value; var url = "tampilboneka.php?boneka=" + nama_boneka; ambilData(url, "info_boneka"); } function validasi() { var elemen_boneka = document.getElementById("id_boneka"); var nama_boneka = elemen_boneka.value; var elemen_banyak = document.getElementById("id_banyak"); var banyak = elemen_banyak.value; if(nama_boneka == "--") { alert("Harap memilih boneka terlebih dahulu"); elemen_boneka.focus(); return false; } var filter = /^([0-9])/; if(!filter.test(banyak)) { alert("Banyak barang yang dibeli harus berupa angka!"); elemen_banyak.focus(); return false; } return true; } </script> <link rel="stylesheet" href="desain.css" type="text/css" /> </head> <body> <img src="image/title.png" /><br /> <div id="menu"><a href="utama.php"><b>HOME</b></a> | <a href="cart.php"><b>CART</b></a></div><br /><br /> <form action="masukkecart.php" method="POST" onsubmit="return validasi();"> <select name="selectboneka" id="id_boneka" onchange="tampilkanBoneka();" > <?php require_once("koneksi.php"); $sql = "SELECT Nama_Boneka FROM tabel_boneka ORDER BY Nama_Boneka"; $hasil = mysql_query($sql); if($hasil) { echo "<option value='--' selected='selected'>-- Pilih Boneka --</option>\n"; while($baris = mysql_fetch_row($hasil)) { $boneka = $baris[0]; echo "<option value=\"$boneka\">$boneka</option>\n"; } } mysql_close($id_mysql); ?> </select> <div id="info_boneka"></div> Jumlah yang mau dibeli: <input type="text" name="banyak" size="1" maxlength="1" id="id_banyak" /><br /> <input type="submit" value="Tambahkan ke Shopping Cart!" /> </form> </body> </html>
file tampilboneka.php - Spoiler:
- Code:
-
<?php header("Cache-Control: no-cache, must-revalidates"); header("Expires: Mon, 26 Jul 1997 00:00:00 GMT"); require_once("koneksi.php"); $boneka = $_GET["boneka"]; $sql = "SELECT * FROM tabel_boneka WHERE Nama_Boneka = '$boneka'"; $hasil = mysql_query($sql); if(!$hasil) echo "Query tak dapat diproses"; else { $baris = mysql_fetch_row($hasil); $data_ada = TRUE; if(empty($baris)) { echo "Silahkan pilih boneka yang akan dibeli!"; $data_ada = FALSE; } if($data_ada) { echo "<table>"; echo "<tr><td width='200px'rowspan='4'>$baris[1]</td>"; echo "<td>Nama Boneka: $baris[0]</td>"; echo "<tr><td>Harga: $baris[2]</td></tr>"; echo "<tr><td>Stock: $baris[3]</td></tr>"; echo "<tr><td>Dalam Shopping Cart Anda: $baris[4]</td></tr>"; echo "</table>"; } } ?>
file masukkecart.php - Spoiler:
- Code:
-
<?php require_once("koneksi.php");
$boneka = $_POST["selectboneka"]; $banyak = (integer)$_POST["banyak"]; $sql = "SELECT * FROM tabel_boneka WHERE Nama_Boneka = '$boneka'"; $hasil = mysql_query($sql); if(!hasil) echo "Query tak dapat diproses"; else { $baris = mysql_fetch_row($hasil); $banyak_awal = $baris[4]; $banyak += $banyak_awal; $sql = "UPDATE tabel_boneka SET Jumlah = '$banyak' WHERE Nama_Boneka = '$boneka'"; $hasil = mysql_query($sql); if(!hasil) echo("Query tak dapat diproses"); else { echo "<html><head><title>Terima Kasih</title>"; echo "<link rel='stylesheet' href='desain.css' type='text/css' />"; echo "</head><body>"; echo "<img src='image/title.png' /><br />"; echo "<div id='menu'><a href='utama.php'><b>HOME</b></a> | <a href='cart.php'><b>CART</b></a></div><br /><br />"; echo "Barang telah dimasukkan ke dalam shopping Cart Anda. Terima Kasih.<br />"; echo "Banyak $boneka Anda dalam Shopping Cart Anda menjadi $banyak. <br /> <br />"; echo "Kembali ke <a href='utama.php'>halaman utama</a><br />"; echo "Lihat <a href='cart.php'>Shopping Cart</a><br />"; echo "</body></html>"; } } mysql_close($id_mysql); ?>
file cart.php - Spoiler:
- Code:
-
<?php require_once("koneksi.php"); $sql = "SELECT * FROM tabel_boneka"; $hasil = mysql_query($sql); if(!$hasil) echo "Query tak dapat diproses"; else { $total = 0; echo "<html><head><title>Shopping Cart</title>"; echo "<link rel='stylesheet' href='desain.css' type='text/css' />"; echo "</head><body>"; echo "<img src='image/title.png' /><br />"; echo "<div id='menu'><a href='utama.php'><b>HOME</b></a> | <a href='cart.php'><b>CART</b></a></div><br /><br />"; echo "<table>"; echo "<tr><td width=\"150px\">Nama</td>"; echo "<td width=\"150px\">Gambar</td>"; echo "<td width=\"150px\">Jumlah yang dibeli</td>"; echo "<td width=\"150px\"></td>"; echo "<td width=\"150px\">Harga per boneka</td>"; echo "<td width=\"150px\">Stock yang tersedia</td></tr>"; while($baris = mysql_fetch_row($hasil)) { $nama = $baris[0]; $gambar = $baris[1]; $harga = $baris[2]; $stock = $baris[3]; $jumlah = $baris[4]; $total += $jumlah*$harga; echo "<tr><td>$nama</td>"; echo "<td>$gambar</td>"; echo "<td>$jumlah</td>"; echo "<td><a href=\"batal.php?nama=$nama\">Keluarkan dari cart</a></td>"; echo "<td>$harga</td>"; echo "<td>$stock</td></tr>"; } echo "</table>"; echo "Total Harga: $total<br />"; echo "<form action=\"beli.php\">"; echo "<input type='submit' value='BELI!!'>"; echo "</form>"; echo "</body></html>"; } mysql_close($id_mysql); ?>
file batal.php - Spoiler:
- Code:
-
<?php require_once("koneksi.php"); $boneka = $_GET["nama"]; $sql = "SELECT * FROM tabel_boneka WHERE Nama_Boneka = '$boneka'"; $hasil = mysql_query($sql); if(!hasil) echo "Query tak dapat diproses"; else { $baris = mysql_fetch_row($hasil);
$sql = "UPDATE tabel_boneka SET Jumlah = 0 WHERE Nama_Boneka = '$boneka'"; $hasil = mysql_query($sql); if(!hasil) echo("Query tak dapat diproses"); else { echo "<html><head><title>Terima Kasih</title>"; echo "<link rel='stylesheet' href='desain.css' type='text/css' />"; echo "</head><body>"; echo "<img src='image/title.png' /><br />"; echo "<div id='menu'><a href='utama.php'><b>HOME</b></a> | <a href='cart.php'><b>CART</b></a></div><br /><br />"; echo "Banyak $boneka Anda dalam Shopping Cart Anda menjadi 0. <br /> <br />"; echo "Kembali ke <a href='utama.php'>halaman utama</a><br />"; echo "Lihat <a href='cart.php'>Shopping Cart</a><br />"; echo "</body></html>"; } } mysql_close($id_mysql); ?>
file beli.php - Spoiler:
- Code:
-
<?php require_once("koneksi.php"); $sql = "SELECT * FROM tabel_boneka"; $hasil = mysql_query($sql); if(!$hasil) echo "Query tak dapat diproses"; else { $stock_cukup = TRUE; $total = 0; while($baris = mysql_fetch_row($hasil)) { $harga = $baris[2]; $stock = $baris[3]; $banyak = $baris[4]; $boneka[] = $baris[0]; $total += $banyak * $harga; if($stock > $banyak) $stock_sisa[] = $stock - $banyak; else $stock_cukup = FALSE; } echo "<html><head><title>Terima Kasih</title>"; echo "<link rel='stylesheet' href='desain.css' type='text/css' />"; echo "</head><body>"; echo "<img src='image/title.png' /><br />"; echo "<div id='menu'><a href='utama.php'><b>HOME</b></a> | <a href='cart.php'><b>CART</b></a></div><br /><br />"; if($stock_cukup) { for($i = 0; $i < count($boneka); $i++) { $sql = "UPDATE tabel_boneka SET Stock = '$stock_sisa[$i]', Jumlah = 0 WHERE Nama_Boneka = '$boneka[$i]'"; $hasil = mysql_query($sql); if(!$hasil) echo "Query tak dapat diproses"; } echo "Terima Kasih. Anda telah melakukan pembelian seharga $total.<br /><br />"; } else { echo "Maaf, salah satu dari barang yang Anda beli tidak cukup stocknya.<br /><br />"; } echo "Kembali ke <a href='utama.php'>halaman utama</a><br />"; echo "Lihat <a href='cart.php'>Shopping Cart</a><br />"; echo "</body></html>"; } mysql_close($id_mysql); ?>
simpan semua file itu dalam folder yang sama, yang diberi nama "tugas_pemrograman_web" (harus!). dalam folder itu, buat 1 folder baru bernama image. Lalu, di dalam folder masukkan gambar apa saja dengan nama: bg_menu.png (kalau bisa ukuran 900 x 38) title.png image2.jpg, image11.jpg, image14.jpg, image16.jpg, image36.jpg, dan image29.jpg itu aja, singkat bukan? hanya web toko online sederhana . Setelah kuketik panjang begini, entah mengapa, aku kok merasa bagusan kuupload aja semua file nya ya? file indexnya adalah file utama.php Cara mengimport database dan cara membuka file php dah tau kan?
Terakhir diubah oleh hart tanggal 2010-03-21, 19:08, total 2 kali diubah | |
| | | wltr3565 Senior
Posts : 870 Thanked : 28 Engine : RMVX Skill : Skilled Type : Scripter
Trophies
Awards:
| Subyek: Re: Ask Java Script dan PHP 2010-03-21, 18:56 | |
| @rei: java (bukan pulau jawa ato jawa barat dan provinsi sekitar) dan javascript pada dasarnya sama (kayak ruby dan rgss). Bedanya java kayak ruby, perlu compiler. Javascript untuk web. Dia pasti mau ujian praktek komputer... | |
| | | shikami Member 1000 Konsep
Posts : 3744 Thanked : 31 Engine : Multi-Engine User Skill : Beginner Type : Developer
Trophies
Awards:
| Subyek: Re: Ask Java Script dan PHP 2010-03-21, 19:04 | |
| @hart~weh edyaaan~ bkin game mobile dh klo gtu wkwkwk..ntar ajak2 ane klo spriting ...btw javascript bwt pemrogaman yg gmn? gw awam abiez | |
| | | hart Senior
Posts : 805 Thanked : 38 Engine : Other Skill : Very Beginner Type : Developer
| Subyek: Re: Ask Java Script dan PHP 2010-03-21, 19:10 | |
| @om shikami: lah? apa hubungannya dengan mobile game? klo ga salah mobile game kebanyakan kan pake J2ME? (maaf kalau salah ) Javascript banyak digunakan untuk pemrograman web pada sisi client(client-side), seperti validasi form, memberi efek2, misalnya timer, dll. PHP banyak digunakan untuk permrograman web pada sisi server(server-side), seperti pengaksesan database, dll (dan lupa lagi ) maaf kalau salah | |
| | | DrDhoom Doomed Zombie
Posts : 629 Thanked : 22 Engine : Multi-Engine User Skill : Intermediate Type : Scripter
| Subyek: Re: Ask Java Script dan PHP 2010-03-21, 20:43 | |
| Wow... kk Hart hebat nih... Ajarin donk... Java aq blum bsa, PHP bnyk yg lupa | |
| | | Durea Novice
Posts : 161 Thanked : 3 Engine : RMVX
| Subyek: Re: Ask Java Script dan PHP 2010-03-22, 05:20 | |
| Tepok tangan buat hart.... gw hanya bisa melihat tutor yang lengkap wow... cuma ngerti yang desain.css [mang ni trid ngomongin CSS] btw,setau gw PHP g cuma buat nyambungin ke mySQL kan ? bisa berguna buat yang lain selain buat databasing..... soalnya tutor yg gw liat database semua.....ato karena gw lom liat semua | |
| | | NewJessy Novice
Posts : 223 Thanked : 4 Engine : RMXP Skill : Beginner Type : Artist
| Subyek: Re: Ask Java Script dan PHP 2010-03-22, 17:55 | |
| @Hart Wah Hebat Hebat tengkyu yee (sst saia sebenaranya punya bukunya!) wkawkawka | |
| | | Ddks Newbie
Posts : 4 Thanked : 0 Engine : RMVX
| Subyek: Re: Ask Java Script dan PHP 2010-04-19, 20:53 | |
| kalo JS sama PHP emang bidang saya dari dulu.. emang mau yg gimana? buat apa? kalo buatin web + CMS super cool, order ke saya aja (promosi dikit ) | |
| | | Sponsored content
| Subyek: Re: Ask Java Script dan PHP | |
| |
| | | | Ask Java Script dan PHP | |
|
| Permissions in this forum: | Anda tidak dapat menjawab topik
| |
| |
| Latest topics | » [Web Novel] Gloria Infidelis by LightNightKnight 2016-11-17, 21:27
» [Announcement] Forum baru untuk RMID by TheoAllen 2016-08-25, 16:39
» Where I'm Wrong ? by ReydVires 2016-07-24, 16:10
» flakeheartnet's Resources part III by flakeheartnet 2016-07-08, 14:30
» Keira's Art Warehouse by KeiraBlaze 2016-06-28, 19:27
» Theo Core Time System + Bingung by Lockin 2016-06-27, 16:24
» Error Script, Maybe ? by Lockin 2016-06-27, 16:20
» Nusaimoe @ RMID Lounge by Jihad Bagas 2016-06-21, 05:02
» Call Random Battle by Lockin 2016-06-15, 17:04
» Flakeheartnet Resources Part II [come back gift] by flakeheartnet 2016-06-07, 15:51
|
Statistics
|
Members: [ 4947 ]
Topics: [ 8258 ]
Posts: [ 112606 ]
Newest member: [ https://rmid.forumotion.net/u4968 ]
|
|
|
|