rianto isaac's Weblog

rianto utomo isaac sahala utomo

php-mssql, hitung via stored procedure dan database

leave a comment »

jajal1.php

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
</head>

<body>
<form id=”form1″ name=”form1″ method=”post” action=”jajal.php”>
<label>bilangan 1
<input type=”text” name=”bil1″ />
</label>
<p>
<label>bilangan 2
<input type=”text” name=”bil2″ />
</label>
</p>
<p>
<label>hitung
<input type=”submit” name=”Submit” value=”Submit” />
</label>
<br />
</p>
</form>
</body>
</html>

——————————————————————————————————————————————————-

jajal.php

<?php
$bil1 = $_POST[bil1];
$bil2 = $_POST[bil2];
//echo $bil1.$bil2; exit;
include “inCbyRianto.php”;
$cari = “exec rianto..jajal $bil1,$bil2″;
//echo $cari; exit;
$jalan=mssql_query($cari);
while($cetak=mssql_fetch_array($jalan))
{ echo $cetak[hsl] ; }
?>
<br />
<br />
<br />
<br />
<br />
<a href=”jajal1.php”>coba lagi</a>

———————————————————————————————————————————————————-

stored procedure

CREATE procedure jajal @bil1 money, @bil2 money

as

delete tbl_jajal

insert into tbl_jajal (bil1, bil2, hsl) values (@bil1, @bil2, @bil1+@bil2)

select hsl from tbl_jajal
GO

————————————————————————————————————————————————————

tabel

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tbl_jajal]’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)
drop table [dbo].[tbl_jajal]
GO

CREATE TABLE [dbo].[tbl_jajal] (
[bil1] [money] NULL ,
[bil2] [money] NULL ,
[hsl] [money] NULL
) ON [PRIMARY]
GO

——————————————————————————————————————————————————-

cost effectiveness = 100%

rianto utomo bikin sendiri

Written by isaaconi

Februari 27, 2013 pada 3:01 pm

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

%d blogger menyukai ini: