script diskon php dalam satu form

<html>
<head>
<title></title>
</head>
<body>
<form method=”POST” action=””>
<h1>Toko majujaya.com</h1>

<table>
<tr>
<td>Nama Barang</td>
<td><input type=”text” name=”bil1″ /></td>
<tr>
<tr><br>
<td>Harga</td>
<td><input type=”text” name=”bil2″ /></td>
</tr>
<tr>
<tr><br>
<td>Quantity</td>
<td><input type=”text” name=”bil3″ /></td>
</tr>

<tr>
<td>
<label>
<input type=”submit” name=”Submit” value=”submit” id=”efrih”>
</label>
</td>
</tr>
</table>

</form>
<div id=”hasil”>

<?php
//
$bilangan1=$_POST[‘bil1’];// namabarang
$bilangan2=$_POST[‘bil2’];// harga
$bilangan3=$_POST[‘bil3’];// quantity

$bayar=($bilangan2*$bilangan3); {
echo “harga barang : Rp. $bayar,”;

}
if ($bayar >= 500000) {
$diskon=(($bayar*27)/100);
$total_bayar=($bayar-$diskon);
echo “$bilangan2”;
echo “<p>”;
echo “total bayar dengan diskon : Rp. $total_bayar,”;}

elseif ($bayar <= 500000) {echo “anda tidak mendapat diskon”;}
?>
<p>
<h4>Trimakasi atas kunjungan anda.</h4>
</p>
</div>
</div>
</div>
</body>
</html>

edit,hapus,simpan foxpro

contoh tabel

contoh tabel

command “click” pada simpan

*STORE SQLSTRINGCONNECT (“DRIVER=SQL SERVER;DATABASE=simakda_kalbar;UID=SA;PWD=SA;SERVER=(LOCAL)”) TO A
Store Sqlstringconnect(“dsn=Test;uid=sa;pwd=”) To a

MESSAGEBOX(a)
kode=thisform.text1.Value
nama=thisform.text2.Value
lama=thisform.text3.Value

E = SQLEXEC(A,”INSERT INTO Jabatan(Kd_jabatan,Nama_jabatan,Lama_kontrak) VALUES (?kode,?nama,?lama)”)
IF E<0
MESSAGEBOX(“ERROR”)
ENDIF
thisform.grid1.Refresh

SQLEXEC(A,”SELECT * FROM Jabatan”,”X”)
SELECT * FROM X

command “click” pada edit

*STORE SQLSTRINGCONNECT (“DRIVER=SQL SERVER;DATABASE=simakda_kalbar;UID=SA;PWD=SA;SERVER=(LOCAL)”) TO A
Store Sqlstringconnect(“dsn=Test;uid=sa;pwd=”) To a

MESSAGEBOX(a)
kode=thisform.text1.Value
nama=thisform.text2.Value
lama=thisform.text3.Value
SQLEXEC(A,”SELECT * FROM Jabatan”,”X”)
SELECT * FROM X

command “click” pada delete

*STORE SQLSTRINGCONNECT (“DRIVER=SQL SERVER;DATABASE=simakda_kalbar;UID=SA;PWD=SA;SERVER=(LOCAL)”) TO A
Store Sqlstringconnect(“dsn=Test;uid=sa;pwd=”) To a

MESSAGEBOX(a)
kode=thisform.text1.Value
nama=thisform.text2.Value
lama=thisform.text3.Value

DELETE
thisform.text1.Value=””
thisform.text2.Value=””
thisform.text3.Value=””
thisform.text1.SetFocus
thisform.grid1.Refresh
SQLEXEC(A,”SELECT * FROM Jabatan”,”X”)
SELECT * FROM X

command “click” pada reset

thisform.text1.Value=”
thisform.text2.Value=”
thisform.text3.Value=”

 form1, “activate” 

*STORE SQLSTRINGCONNECT (“DRIVER=SQL SERVER;DATABASE=simakda_kalbar;UID=SA;PWD=SA;SERVER=(LOCAL)”) TO

SET DELETED on

VB code sederhana input data

 

 

 

 

 

 

 

 

(1) buat tabel seperti diatas…!!!

ketik code di bawah ini

Private Sub kosongkan()

txtkdkk = “”
txtnmkepkel = “”
txttmplahir = “”
DTPicker1 = Value
cboagama = “”
txtkerjabpk = “”
txtalamat = “”
txtrtrw = “”
txtkota = “”
txtnmibu = “”
txtkerjaibu = “”
txtanaklaki = “”
txtanakprp = “”
txtcari = “”
End Sub

Private Sub cmdclear_Click()
kosongkan
End Sub

Private Sub cmdkeluar_Click()
End
End Sub

Private Sub cmdview_Click()
Form2.Show
End Sub

Private Sub cmdsimpan_Click()
With Form2.Adodc1.Recordset
.AddNew
!kd_kk = txtkdkk
!nm_kepkel = txtnmkepkel
!tmp_lahir = txttmplahir
!tgl_lahir = DTPicker1
!agama = cboagama
!pekerjaan = txtkerjabpk
!alamat = txtalamat
!rt_rw = txtrtrw
!kota = txtkota
!nm_ibu = txtnmibu
!pekerjaan_ibu = txtkerjaibu
!jml_anaklaki = txtanaklaki
!jml_anakperempuan = txtanakprp
.Update
Form2.DataGrid1.Refresh
End With
kosongkan
End Sub

Private Sub cmdcari_Click()
Dim cari As String * 20
cari = txtcari.Text
Form2.Adodc1.Recordset.MoveFirst
Form2.Adodc1.Recordset.Find “kd_kk = ‘” & cari & “‘”
If Form2.Adodc1.Recordset.EOF Then
pesan = MsgBox(“Kode KK tidak ada..”, vbOKOnly, “Pesan Program”)
Form2.Adodc1.Recordset.MoveFirst
Else
txtkdkk.Text = Form2.Adodc1.Recordset.Fields(“kd_kk”)
txtnmkepkel.Text = Form2.Adodc1.Recordset.Fields(“nm_kepkel”)
txtkerjabpk.Text = Form2.Adodc1.Recordset.Fields(“pekerjaan”)
txttmplahir.Text = Form2.Adodc1.Recordset.Fields(“tmp_lahir”)
DTPicker1.Value = Form2.Adodc1.Recordset.Fields(“tgl_lahir”)
cboagama.Text = Form2.Adodc1.Recordset.Fields(“agama”)
txtalamat.Text = Form2.Adodc1.Recordset.Fields(“alamat”)
txtrtrw.Text = Form2.Adodc1.Recordset.Fields(“rt_rw”)
txtkota.Text = Form2.Adodc1.Recordset.Fields(“kota”)
txtnmibu.Text = Form2.Adodc1.Recordset.Fields(“nm_ibu”)
txtkerjaibu.Text = Form2.Adodc1.Recordset.Fields(“pekerjaan_ibu”)
txtanaklaki.Text = Form2.Adodc1.Recordset.Fields(“jml_anaklaki”)
txtanakprp.Text = Form2.Adodc1.Recordset.Fields(“jml_anakperempuan”)
Form2.Show
txtcari.Text = “”
End If
End Sub

Private Sub Form_Load()
cboagama.AddItem “Buddha”
cboagama.AddItem “Hindhu”
cboagama.AddItem “Islam”
cboagama.AddItem “Katolik”
cboagama.AddItem “Kristen”
End Sub

 

 

 

 

 

 

 

Private Sub cmdback_Click()
Form1.Show
Form2.Visible = False
End Sub

Private Sub cmdhapus_Click()
Adodc1.Recordset.Delete
Adodc1.Recordset.Update
Adodc1.Recordset.MoveFirst
Form1.txtkdkk = “”
Form1.txtnmkepkel = “”
Form1.txttmplahir = “”
Form1.DTPicker1 = Value
Form1.cboagama = “”
Form1.txtkerjabpk = “”
Form1.txtrtrw = “”
Form1.txtalamat = “”
Form1.txtkota = “”
Form1.txtnmibu = “”
Form1.txtkerjaibu = “”
Form1.txtanaklaki = “”
Form1.txtanakprp = “”
End Sub

CONTOH PENERAPAN HTML FORM

 

 

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”

http://www.w3.org/TR/html4/loose.dtd”&gt;

<html>

<head>

<title>Regristrasi</title>

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>

</head>

 

<body>

<h2>Form Regristrasi</h2>

<form action=””method=”post”>

</form>

<label>Nama    :  </label>

<input type=”text” size=”30″name=”nama”><br>

<label>Username :</label>

<input type=”text” size=”16″ name=”uname” maxlengt=”16″><br>

<label>Password : </label>

<input type=”Password” size=”16″ name=”pass” maxlength=”16″><br>

<label>Jenis Kelamin</label>

<input type=”radio” name=”jk” value=”pria”>

<span>pria</span>

<input type=”radio” name=”jk” value=”wanita”>

<span>wanita</span>

<br><br>

<label>Hoby :</label><br>

<input type=”checkbox” name=”hob” value=”spkbola”><span>Sepak Bola</span>

<input type=”checkbox” name=”hob” value=”game”><span>Game</span>

<input type=”checkbox” name=”hob” value=”tidur”>

<span>Tidur</span><br>

<label>Diskripsi diri anda :</label>

<br>

<textarea style=”height:100px;width:400px ” name=”desc”></textarea>

<hr>

<label>Darimana anda mendengar kami?</label><br>

<select name=”dengar”>

<option value=”kuburan”>Dari pacar</option>

<option value=”google”>Google</option>

<option value=”mimpi”>Mimpi</option>

</select><br>

<input type=”submit” value=”DAFTAR”>

<input type=”reset” value=”RESET”>

</form>

<hr>

<img src=”http://img193.imageshack.us/img193/4705/bocahamalmain.jpg&#8221; align=”top”

<br>

<img src=”http://t1.gstatic.com/images?q=tbn:d2fhcIANvvep7M:http://mulia2me.files.wordpress.com/2009/01/8001051ik22.jpg&#8221; align=”top”

<img src=”http://t2.gstatic.com/images?q=tbn:EXP6d_giEHkCXM:http://img.photobucket.com/albums/v96/starlightexpress/jun_06/June06-020.jpg&#8221;

</body>

</html>

 

CONTOH PENULISAN CSS

 

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”

http://www.w3.org/TR/html4/loose.dtd”&gt;

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>

</head>

<title>CSS Cascading Style Sheets</title>

<style type=”text/css”></style>

Body { fontfamily:Verdana,Serif; fontsize:11px }

div {

border: 2px solid#cccccc;

padding:4px

}

h2  {

textdecoration;

underline;

fontstyle:italic;

fontsize:18px

}

</style>

</head>

<body>

<div>

<h2>Ini adalah contoh sederhana penggunaan CSS</h2>

</div>

</body>

</html>

contoh script toko online

koneksi.php

 

<?php

$server=”localhost”;

$username =”root”;

$password =””;

$database =”dtbarang”;

mysql_connect($server,$username,$password) or die(“gagal”);

mysql_select_db($database) or die(“Database tidak ditemukan”);

?>

 

 

prosesinput.php

 

<?php

include(“koneksi.php”);

mysql_query (“INSERT INTO dtbarang(kd_barang, nm_barang, harga) VALUES(‘$_POST[kd_barang]’,’$_POST[nm_barang]’,’$_POST[harga]’)”);

echo(“<table>”);

echo(“<tr><td>Kode Barang</td> <td>: <b>$_POST[kd_barang]</b></td></tr>”);

echo(“<tr><td>Nama Barang</td> <td>: <b>$_POST[nm_barang]</b></td></tr>”);

echo(“<tr><td>Harga Barang</td> <td>: <b>$_POST[harga]</b></td></tr>”);

echo(“<tr><td><form method=post action=tampil.php>”);

echo(“<input type=submit name=submit value=’Lihat Data’></form></td>”);

echo(“<td><form method=post action=input.php>”);

echo(“<input type=submit name=submit value=’Daftar lagi’></form></td></tr></table>”);

?>

 

 

tampil.php

 

<?php

echo(“DATA SISWA<br><hr><br>”);

echo(“<table border=1>”);

echo(“<tr><td>Kode Barang</td><td>Nama Barang</td><td>Harga Barang</td></tr>”);

include(“koneksi.php”);

$perintah=”select * from dtbarang order by harga”;

$tampil_data=mysql_query($perintah);

while($data=mysql_fetch_row($tampil_data))

{

echo(“<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>

<a href=edit.php?id=$data[0]>Edit</a></td><td>

<a href=hapus.php?id=$data[0]>Hapus</a></td></tr>”);

}

echo(“</table>”);

echo(“<form method=post action=input.php>”);

echo(“<input type=submit name=submit value=’Daftar Lagi’></form>”);

?>

 

 

update.php

 

<?php

include (“koneksi.php”);

mysql_query(“UPDATE tbbarang SET dt_barang=’$_POST[kd_barang]’, nm_barang=’$_POST[nm_barang]’, harga=’$_POST[harga]’ where kd_barang=’$_POST[kd_barang]’ “);

?>

 

 

hapus.php

 

<?php

include(“koneksi.php”);

mysql_query(“DELETE FROM tbbarang where dt_barang=’$_GET[id]'”);

?>

 

input.php

 

<html>

 

INPUT DATA BARANG

<table>

<form method=post action = prosesinput1.php>

<tr><td>Kode Barang</td><td>: <input type = text name=kd_barang size=25><br></td></tr>

<tr><td>Nama Barang</td><td>: <input type = text name=nm_barang size=30><br></td></tr>

<tr><td>Harga Barang</td><td>: <input type = text name=harga size=30> </td></tr>

<tr><td><input type=submit name=submit value=Proses></td>

<td><input type=reset name=reset value=Batal></td></tr>

</form>

</table>

</html>

 

 

 

edit1.php

 

<?php

include(“koneksi.php”);

$edit=mysql_query(“select * dtbarang where kd_barang=’$_GET[id]'”);

echo”<h2>Edit Data</h2>

<form method=POST action=update.php><table>

<tr><td>Kode Barang</td><td>: <input type=text name=kd_barang value=’$data[kd_barang]’>

</td></tr>

<tr><td>Nama Barang</td><td>: <input type=text name=nm_barang value=’$data[nm_barang]’>

</td></tr>

<tr><td>Harga Barang</td><td>: <input type=text name=harga value=’$data[harga]’>

</td></tr>

<tr><td colspan=2><input type=submit value=update>

<input type=button value=Batal onclick=self.history.back()></td></tr>

</table></form>”;

?>

 

 

transaksi.php

 

<?

 

 

 

?>

<?php

 

//buat variabel untuk menampung data dari file .html

$kaos_volcom = $_POST[‘kaos_volcom’]; //data kaos

$kaos_oneill = $_POST[‘kaos_oneill’];//data kaos

$jaket_cosmic = $_POST[‘jaket_cosmic’]; //data jaket

$jaket_ouval = $_POST[‘jaket_ouval’]; //data jaket

$sepatu_converse = $_POST[‘sepatu_converse’]; //data sepatu

 

//harga dari masingmasing produk

define(‘HARGA_KAOS1’,175000);

define(‘HARGA_KAOS2’,125000);

define(‘HARGA_JAKET1’, 225000);

define(‘HARGA_JAKET2’, 265000);

define(‘HARGA_SEPATU’, 275000);

 

//total harga

$total = (HARGA_KAOS1 * $kaos_volcom) + (HARGA_KAOS2 * $kaos_oneill) +

(HARGA_JAKET1 * $jaket_cosmic) + (HARGA_JAKET2 * $jaket_cosmic) + (HARGA_SEPATU * $sepatu_converse);

 

$diskon = 0;

$pesan_diskon = ‘0%’;

 

//cek total untuk menentukan diskon

if ($total >= 600000 && $total < 750000) {

$diskon = 0.05; //diskon 5%

$pesan_diskon = ‘5%’;

} elseif ($total >=750000 && $total < 1000000) {

$diskon = 0.1;// diskon 10%

$pesan_diskon = ‘10%’;

} elseif ($total >= 1000000) {

$diskon = 0.15; //diskon 15%

$pesan_diskon = ‘15%’;

}

$subtotal = $total – ($total * $diskon);

 

?>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”

http://www.w3.org/TR/html4/loose.dtd”&gt;

<head>

<title>Pembelian Online</title>

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-8″>

<style type=”text/css”>

.tanda {background-color:#cfcfcf;}

.style12 {

font-size: 24;

color: #FF0000;

}

.style13 {font-size: 24px; color: #000000; }

.style15 {color: #FF0000}

.style16 {

font-size: 24px;

color: #FF0000;

}

body {

background-image: url(background/back.jpg);

}

</style>

</head>

 

<body tracingsrc=”background/back.jpg” tracingopacity=”100″>

<table width=”815″ ></table>

<tr>

<td height=”119″><img src=”Wallpaper_1_1.jpg”width=”900″ height=”200″</td>

</tr>

<tr>

<td height=”573″><div align=”center”>

<p>&nbsp;</p>

<p align=”center”><span> DATA PEMBELIAN </span></p>

<div align=”right”>

<table width=”574″ height=”378″ border=”1″ align=”center”>

<tr>

<td width=”195″><div align=”center” class=”style15″>

<div align=”justify”>Barang</div>

</div></td>

<td width=”196″><div align=”center” class=”style15″>

<div align=”justify”>Jumlah</div>

</div></td>

<td width=”195″><div align=”center” class=”style15″>

<div align=”justify”>Total</div>

</div></td>

</tr>

<tr>

<td><span>Hand guns 1</span></td>

<td><span><?php echo $kaos_volcom;?></span></td>

<td><span><?php echo ($kaos_volcom * HARGA_KAOS1);?></span>

</tr>

<tr>

<td><span>Hand guns 2 </span></td>

<td><span><?php echo $kaos_oneill;?></span></td>

<td><span><?php echo ($kaos_oneill * HARGA_KAOS2);?></span>

</tr>

<tr>

<td><span>Hand guns 3 </span></td>

<td><span><?php echo$jaket_cosmic;?></span></td>

<td><span><?php echo($jaket_cosmic*HARGA_JAKET1);?></span>

</tr>

<tr>

<td><span>Hand guns 4 </span></td>

<td><span><?php echo $jaket_ouval;?></span></td>

<td><span><?php echo ($jaket_ouval * HARGA_JAKET2);?></span>

</tr>

<tr>

<td><span>Hand guns 5 </span></td>

<td><span><?php echo $sepatu_converse;?></span></td>

<td><span><?php echo ($sepatu_converse * HARGA_SEPATU);?></span>

</tr>

<tr class=”tanda”>

<td colspan=”2″><span class=”style15″>TOTAL</span></td>

<td><span class=”style15″><?php echo $total;?></span></td>

</tr>

<tr class=”tanda”>

<td colspan=”2″><span class=”style15″>Diskon</span></td>

<td><span><?php echo $pesan_diskon;?></span></td>

</tr>

<tr class=”tanda”>

<td colspan=”2″><span class=”style15″>SUBTOTAL</span></td>

<td><span><?php echo $subtotal;?></span></td>

</tr>

</table>

</div>

<p>&nbsp;</p>

</div></td>

</tr>

<tr>

<td height=”56″> <img src=”2.jpg” width=”130″ height=”100″> <img src=”colt-tactical-pistol.gif” width=”130″ height=”100″>  <img src=”WilsonHandguns_logo2.jpg” width=”130″ height=”100″>  <img src=”handgun1.jpg” width=”130″ height=”100″>  <img src=”air_sport_gun_m39-2.jpg” width=”130″ height=”100″> <img src=”Wallpaper_1_1.jpg” width=”130″ height=”100″></td>

</tr>

</table>

<p align=”center”>&nbsp;</p>

</body>

</html>

<?

 

?>

PROGRAM MENAMPILKAN DERET BILANGAN

Hasil :

Masukan x = 4

1 2 3 4

2 4 6

3 6

4

3 6

2 4 6

1 2 3 4

 

 

#include <stdio.h>

#include <conio.h>

void main ()

{

clrscr();

int baris, kolom , hasil, x ,y ,m,n,k;

printf(“masukkan x = “);

scanf(“%3d”,&x);

y= x+1;

for (baris =  1 ; baris <= y ; baris++ )

{ for (kolom = 1 ; kolom <= y-baris ; kolom++)

{ hasil = kolom * baris ;

printf(“%3d”,hasil);

}

printf(“\n”);

}

for (m = 4 ; m >= 1 ; m–)

{ for (n = 1 ; n <= y-m ; n++)

{ k=m*n ;

printf(“%3d”,k);

}

printf(“\n”);

}

getch();

}