Commit 50333ef1 by Roy Junedi Simamora

Perubahan fungsi mysql menjadi mysqli

parent a64e2ba8
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<?php <?php
$per_hal = 10; $per_hal = 10;
$jumlah_record = mysql_query("SELECT COUNT(*) from menu"); $jumlah_record = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT COUNT(*) from menu");
$jum = mysql_result($jumlah_record, 0); $jum = mysql_result($jumlah_record, 0);
$halaman = ceil($jum / $per_hal); $halaman = ceil($jum / $per_hal);
$page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1; $page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1;
...@@ -45,13 +45,13 @@ $start = ($page - 1) * $per_hal; ...@@ -45,13 +45,13 @@ $start = ($page - 1) * $per_hal;
</tr> </tr>
<?php <?php
if (isset($_GET['cari'])) { if (isset($_GET['cari'])) {
$cari = mysql_real_escape_string($_GET['cari']); $cari = mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $_GET['cari']);
$menu = mysql_query("select * from menu where nama like '$cari' or kategori_id like '$cari'"); $menu = mysqli_query($GLOBALS["___mysqli_ston"], "select * from menu where nama like '$cari' or kategori_id like '$cari'");
} else { } else {
$menu = mysql_query("select * from menu limit $start, $per_hal"); $menu = mysqli_query($GLOBALS["___mysqli_ston"], "select * from menu limit $start, $per_hal");
} }
$no = 1; $no = 1;
while ($b = mysql_fetch_array($menu)) { while ($b = mysqli_fetch_array($menu)) {
?> ?>
<tr> <tr>
<td><?php echo $no++ ?></td> <td><?php echo $no++ ?></td>
......
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
$email = $_POST['email']; $email = $_POST['email'];
$comment = $_POST['comment']; $comment = $_POST['comment'];
} }
$query = "INSERT INTO komentar VALUES('','$nama','$comment', '$email', '$hp')";
$input = mysql_query("INSERT INTO komentar VALUES('','$nama','$comment', '$email', '$hp')") or die(mysql_error()); $input = mysqli_query($koneksi, $query) or die(mysqli_error($GLOBALS["___mysqli_ston"]));
if($input){ if($input){
header('Location: form_comment.php'); header('Location: form_comment.php');
}else{ }else{
......
...@@ -27,16 +27,16 @@ ...@@ -27,16 +27,16 @@
//jika user telah memasukkan semua data yang dibutuhkan, koreksi kata sandi //jika user telah memasukkan semua data yang dibutuhkan, koreksi kata sandi
if($pass == $repass){ if($pass == $repass){
//mengambil informasi dari nama tabel "member" pada kolom "nama" //mengambil informasi dari nama tabel "member" pada kolom "nama"
$ambilDataSql = mysql_query("SELECT * FROM member WHERE username = '$uname'"); $ambilDataSql = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM member WHERE username = '$uname'");
//mengambil informasi dari seluruh kolom nama //mengambil informasi dari seluruh kolom nama
$cek_username = mysql_num_rows($ambilDataSql); $cek_username = mysqli_num_rows($ambilDataSql);
$ambilDataMember = mysql_query("SELECT * FROM member"); $ambilDataMember = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM member");
$countData = mysql_num_rows($ambilDataMember); $countData = mysqli_num_rows($ambilDataMember);
//mengecek ketersediaan identitas //mengecek ketersediaan identitas
if($cek_username == 0){//jika nama tidak ditemukan/belum terdaftar if($cek_username == 0){//jika nama tidak ditemukan/belum terdaftar
//lakukan penambahan data //lakukan penambahan data
$id = $countData +1; $id = $countData +1;
mysql_query("INSERT INTO member VALUES($id,'$nama','$address','$hp','$uname','$pass','$email')"); mysqli_query($GLOBALS["___mysqli_ston"], "INSERT INTO member VALUES($id,'$nama','$address','$hp','$uname','$pass','$email')");
echo "pendaftaran berhasil"; echo "pendaftaran berhasil";
}else{ }else{
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
<h2> Daftar Feedback </h2> <h2> Daftar Feedback </h2>
<hr/> <hr/>
<?php <?php
$komen = mysql_query("SELECT * FROM komentar"); $komen = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM komentar");
while($q = mysql_fetch_array($komen)){ while($q = mysqli_fetch_array($komen)){
?> ?>
<div class="col-md-4"> <div class="col-md-4">
<div class="thumbnail"> <div class="thumbnail">
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'koneksi.php'; require 'koneksi.php';
$id = $_GET['id']; $id = $_GET['id'];
mysql_query("delete from menu where id_menu = '$id'"); mysqli_query($GLOBALS["___mysqli_ston"], "delete from menu where id_menu = '$id'");
header('Location: admin_menu.php'); header('Location: admin_menu.php');
?> ?>
...@@ -9,52 +9,22 @@ require 'koneksi.php'; ...@@ -9,52 +9,22 @@ require 'koneksi.php';
<h3><span class="glyphicon glyphicon-eye-open"></span> Menu Detail </h3> <h3><span class="glyphicon glyphicon-eye-open"></span> Menu Detail </h3>
<div class="row"> <div class="row">
<?php <?php
$id = ($_GET['id']); $id = $_GET['id'];
$det = mysql_query("select * from menu where id_menu ='$id'")or die(mysql_error());
while ($detail = mysql_fetch_array($det)) {
?> ?>
<div class="col-md-6"> <div class="col-md-12">
<div align="center"><img src="picture/<?php echo $detail['gambar'] ?>" class="img-thumbnail" width="300" height="300"> </div> <div class="billInfo grid_11 alpha">
</div> <form method="post" action="pesan_proses.php?id=<?php echo $id; ?>" id="comment_form">
<div class="col-md-6"> <fieldset>
<form action="pesan_proses.php?id=<?php echo $id; ?>" action="post"> <label for="Jumlah">Jumlah: </label>
<table class="table" align="center" width="100%"> <input type="text" tabindex="1" size="22" value="" name="jumlah" class="text" />
<tr> <input type="submit" value="Pesan"/>
<td>Nama</td>
<td><?php echo $detail['nama'] ?></td>
</tr>
<tr>
<td>Harga</td>
<td>Rp.<?php echo number_format($detail['harga']) ?>,-</td>
</tr>
<tr> </fieldset>
<td> Kategori </td>
<td>
<?php
if ($detail['kategori_id'] = 1) {
echo 'Makanan';
} else if ($detail['kategori_id'] = 2) {
echo 'Minuman';
}
?>
</td>
</tr>
<tr>
<td> Jumlah </td>
<td> <input type="text" name="jumlah" tabindex="1" size="22" value="1" > </td>
</tr>
<tr>
<td> <input type="submit" class="btn btn-info" value="Pesan"> </td>
</tr>
</table>
</form> </form>
</div> </div>
<?php </div>
} </div>
?>
</div>
<br/> <br/>
<?php <?php
include 'common/footer.php'; include 'common/footer.php';
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
<h3><span class="glyphicon glyphicon-edit"></span> Edit Menu</h3> <h3><span class="glyphicon glyphicon-edit"></span> Edit Menu</h3>
<a class="btn" href="list_menu.php"><span class="glyphicon glyphicon-chevron-left"></span> Kembali</a> <a class="btn" href="list_menu.php"><span class="glyphicon glyphicon-chevron-left"></span> Kembali</a>
<?php <?php
$id = mysql_real_escape_string($_GET['id']); $id = mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $_GET['id']);
$det = mysql_query("select * from menu where id_menu ='$id'")or die(mysql_error()); $det = mysqli_query($GLOBALS["___mysqli_ston"], "select * from menu where id_menu ='$id'")or die(mysqli_error($GLOBALS["___mysqli_ston"]));
while($d=mysql_fetch_array($det)){ while($d=mysqli_fetch_array($det)){
?> ?>
<form action="edit_proses.php" method="post" enctype="multipart/form-data"> <form action="edit_proses.php" method="post" enctype="multipart/form-data">
<table class="table"> <table class="table">
......
...@@ -9,6 +9,6 @@ ...@@ -9,6 +9,6 @@
move_uploaded_file($_FILES['gambar']['tmp_name'], 'picture/'. $gambar); move_uploaded_file($_FILES['gambar']['tmp_name'], 'picture/'. $gambar);
mysql_query("update menu set nama = '$nama', harga = '$harga', gambar = '$gambar', kategori_id = '$kategori' where id_menu='$id'"); mysqli_query($GLOBALS["___mysqli_ston"], "update menu set nama = '$nama', harga = '$harga', gambar = '$gambar', kategori_id = '$kategori' where id_menu='$id'");
header('Location: admin_menu.php'); header('Location: admin_menu.php');
?> ?>
\ No newline at end of file
...@@ -9,7 +9,7 @@ if(isset($_GET['do_login'])){ ...@@ -9,7 +9,7 @@ if(isset($_GET['do_login'])){
$_SESSION['login_error'] = TRUE; $_SESSION['login_error'] = TRUE;
}else{ }else{
$_SESSION['user'] = TRUE; $_SESSION['user'] = TRUE;
$row = mysql_fetch_assoc($resUsr); $row = mysqli_fetch_assoc($resUsr);
$_SESSION['id_member'] = $row['id_member']; $_SESSION['id_member'] = $row['id_member'];
header("location:index.php"); header("location:index.php");
} }
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
include 'koneksi.php'; include 'koneksi.php';
$id = $_GET['id']; $id = $_GET['id'];
mysql_query("DELETE FROM komentar WHERE id_komentar = '$id'"); mysqli_query($GLOBALS["___mysqli_ston"], "DELETE FROM komentar WHERE id_komentar = '$id'");
header('Location: daftar_komen.php'); header('Location: daftar_komen.php');
?> ?>
\ No newline at end of file
...@@ -3,5 +3,4 @@ $host="127.0.0.1"; ...@@ -3,5 +3,4 @@ $host="127.0.0.1";
$user="root"; $user="root";
$pass=""; $pass="";
$name="p1d3ti04_pondokedo"; $name="p1d3ti04_pondokedo";
$koneksi=mysql_connect($host,$user,$pass)or die("Koneksi ke database gagal!"); $koneksi=($GLOBALS["___mysqli_ston"] = mysqli_connect($host, $user, $pass, $name))or die("Koneksi ke database gagal!");
mysql_select_db($name,$koneksi)or die("Tidak ada database yang dipilih!");
...@@ -8,16 +8,17 @@ include 'common/header.php'; ...@@ -8,16 +8,17 @@ include 'common/header.php';
<?php <?php
$per_hal = 8; $per_hal = 8;
$jumlah_record = mysql_query("SELECT COUNT(*) from menu"); $query = "SELECT COUNT(*) from menu";
$jum = mysql_result($jumlah_record, 0); $jumlah_record = mysqli_query($koneksi, $query);
$jum = mysqli_affected_rows($jumlah_record);
$halaman = ceil($jum / $per_hal); $halaman = ceil($jum / $per_hal);
$page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1; $page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1;
$start = ($page - 1) * $per_hal; $start = ($page - 1) * $per_hal;
?> ?>
<br/> <br/>
<?php <?php
$menu = mysql_query("select * from menu limit $start, $per_hal"); $menu = mysqli_query($GLOBALS["___mysqli_ston"], "select * from menu limit $start, $per_hal");
while ($b = mysql_fetch_array($menu)) { while ($b = mysqli_fetch_array($menu)) {
?> ?>
<div class="col-md-3"> <div class="col-md-3">
......
...@@ -2,17 +2,13 @@ ...@@ -2,17 +2,13 @@
include 'koneksi.php'; include 'koneksi.php';
include 'fungsi/fungsi.php'; include 'fungsi/fungsi.php';
$id = mysql_real_escape_string($_GET['id']); $id = $_GET['id'];
$query = mysql_query("SELECT * menu WHERE id_menu= '$id'");
$q = mysql_fetch_array($query);
$id_member = get_session('id'); $id_member = get_session('id');
$id_menu = $q['id_menu']; $id_menu = $id;
$tanggal = DATE_COOKIE; $tanggal = date('Y-m-d');
$jumlah = $_POST['jumlah']; $jumlah = $_POST['jumlah'];
mysql_query("INSERT INTO pemesanan(member_id, menu_id, tanggal, jumlah) VALUES('$id_member','$id_menu','$tanggal','$jumlah')"); mysqli_query($koneksi, "INSERT INTO pemesanan(member_id, menu_id, tanggal, jumlah,id_pemesanan) VALUES('$id_member','$id_menu','$tanggal','$jumlah','')");
header("Location: detail.php?id=".$id);
?> ?>
\ No newline at end of file
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
$image = $_FILES['gambar']['name']; $image = $_FILES['gambar']['name'];
move_uploaded_file($_FILES['gambar']['tmp_name'], 'picture/' .$image); move_uploaded_file($_FILES['gambar']['tmp_name'], 'picture/' .$image);
mysql_query("insert into menu values('', '$nama' ,'$harga', '$image', '$kategori')"); mysqli_query($GLOBALS["___mysqli_ston"], "insert into menu values('', '$nama' ,'$harga', '$image', '$kategori')");
header('Location: Admin_menu.php'); header('Location: Admin_menu.php');
?> ?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment