Download doc - latihan web2

Transcript
Page 1: latihan web2

+ Latihan +

Buat Rancangan Inputan Dibawah ini!!

Resto.php

Rancangan Outputan.

Output-resto.php

Struktur Database :

Page 2: latihan web2

Daftar Paket :

Tampilan Outputan.

Buat file config.php dengan koneksi database ke restoran_1109xxx

Buat folder resto di dalam folder nim masing2.. simpan semua file didalam folder resto

Page 3: latihan web2

Jawaban :

1. Output menggunakan table

Script :

<body><?mysql_connect("localhost","root","password") or die ("gagal koneksi database".mysql_error());mysql_select_db("restoran_1109xxxx");

if($jenis=="paket1"){$menu="chicken maryland";$harga=50000;}elseif($jenis=="paket2"){$menu="lele saurus";$harga=30000;}else{$menu="beef gordon";$harga=100000;}$total=$harga*$jumbel;if($_POST['simpan']){mysql_query("insert into pesanan (nopes,nama,jenis,menu,harga,jumbel,total) VALUES ('$nopes','$nama','$jenis','$menu','$harga','$jumbel','$total')");}?><table width="650" border="1"> <tr> <td colspan="7"><div align="center">Table Pesanan </div></td>

Page 4: latihan web2

</tr> <tr> <td width="77">No Pesanan </td> <td width="109">Nama Pemesan </td> <td width="98">Jenis Pesanan </td> <td width="102">Menu Makanan </td> <td width="59">Harga</td> <td width="91">Jumlah Beli </td> <td width="68">Total</td> </tr> <? mysql_connect("localhost","root","password"); mysql_select_db("restoran_1109xxxx"); $sql=mysql_query("Select * From pesanan"); while($res=mysql_fetch_array($sql)){ echo" <tr> <td>$res[0]</td> <td>$res[1]</td> <td>$res[2]</td> <td>$res[3]</td> <td>$res[4]</td> <td>$res[5]</td> <td>$res[6]</td> </tr>"; } ?></table><br><a href="resto.php">Input Lagi.....!!!!!</a><br><a href="output-baris.php">Tampil baris....!!!!!</a></body>

2. Output menggunakan baris.

Page 5: latihan web2

Script :

<body> <?php switch($jenis) { case 'paket1':

$menu="chicken maryland";$harga=50000;break;

case 'paket1':$menu="lele saurus";$harga=30000;break;

case 'paket1':$menu="beef gordon";$harga=100000;break;

default:$menu="Salah Input bro";$harga=0;break;

}

include 'config.php'; $sql=mysql_query("Select * From pesanan"); while($res=mysql_fetch_array($sql)){ echo"<pre><h3>Restoran Altavista</h3> No Pesan : $res[0]

Nama : $res[1] Jenis Pesanan : $res[2] Menu Makanan : $res[3] Harga : $res[4] Jumlah Beli : $res[5] Total : $res[6] <hr>

"; } ?></table><br><a href="resto.php">Input Lagi.....!!!!!</a></body>