Commit 50333ef1 by Roy Junedi Simamora

Perubahan fungsi mysql menjadi mysqli

parent a64e2ba8
......@@ -8,8 +8,8 @@
<?php
$per_hal = 10;
$jumlah_record = mysql_query("SELECT COUNT(*) from menu");
$jum = mysql_result($jumlah_record, 0);
$jumlah_record = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT COUNT(*) from menu");
$jum = mysql_result($jumlah_record, 0);
$halaman = ceil($jum / $per_hal);
$page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1;
$start = ($page - 1) * $per_hal;
......@@ -45,13 +45,13 @@ $start = ($page - 1) * $per_hal;
</tr>
<?php
if (isset($_GET['cari'])) {
$cari = mysql_real_escape_string($_GET['cari']);
$menu = mysql_query("select * from menu where nama like '$cari' or kategori_id like '$cari'");
$cari = mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $_GET['cari']);
$menu = mysqli_query($GLOBALS["___mysqli_ston"], "select * from menu where nama like '$cari' or kategori_id like '$cari'");
} 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;
while ($b = mysql_fetch_array($menu)) {
while ($b = mysqli_fetch_array($menu)) {
?>
<tr>
<td><?php echo $no++ ?></td>
......
......@@ -7,8 +7,9 @@
$email = $_POST['email'];
$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){
header('Location: form_comment.php');
}else{
......
......@@ -27,16 +27,16 @@
//jika user telah memasukkan semua data yang dibutuhkan, koreksi kata sandi
if($pass == $repass){
//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
$cek_username = mysql_num_rows($ambilDataSql);
$ambilDataMember = mysql_query("SELECT * FROM member");
$countData = mysql_num_rows($ambilDataMember);
$cek_username = mysqli_num_rows($ambilDataSql);
$ambilDataMember = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM member");
$countData = mysqli_num_rows($ambilDataMember);
//mengecek ketersediaan identitas
if($cek_username == 0){//jika nama tidak ditemukan/belum terdaftar
//lakukan penambahan data
$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";
}else{
......
......@@ -7,8 +7,8 @@
<h2> Daftar Feedback </h2>
<hr/>
<?php
$komen = mysql_query("SELECT * FROM komentar");
while($q = mysql_fetch_array($komen)){
$komen = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM komentar");
while($q = mysqli_fetch_array($komen)){
?>
<div class="col-md-4">
<div class="thumbnail">
......
......@@ -2,7 +2,7 @@
require 'koneksi.php';
$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');
?>
......@@ -9,52 +9,22 @@ require 'koneksi.php';
<h3><span class="glyphicon glyphicon-eye-open"></span> Menu Detail </h3>
<div class="row">
<?php
$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 align="center"><img src="picture/<?php echo $detail['gambar'] ?>" class="img-thumbnail" width="300" height="300"> </div>
</div>
<div class="col-md-6">
<form action="pesan_proses.php?id=<?php echo $id; ?>" action="post">
<table class="table" align="center" width="100%">
<tr>
<td>Nama</td>
<td><?php echo $detail['nama'] ?></td>
</tr>
<tr>
<td>Harga</td>
<td>Rp.<?php echo number_format($detail['harga']) ?>,-</td>
</tr>
$id = $_GET['id'];
?>
<div class="col-md-12">
<div class="billInfo grid_11 alpha">
<form method="post" action="pesan_proses.php?id=<?php echo $id; ?>" id="comment_form">
<fieldset>
<label for="Jumlah">Jumlah: </label>
<input type="text" tabindex="1" size="22" value="" name="jumlah" class="text" />
<input type="submit" value="Pesan"/>
<tr>
<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>
</fieldset>
</form>
</div>
</div>
</div>
<?php
}
?>
</div>
<br/>
<?php
include 'common/footer.php';
......
......@@ -6,9 +6,9 @@
<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>
<?php
$id = mysql_real_escape_string($_GET['id']);
$det = mysql_query("select * from menu where id_menu ='$id'")or die(mysql_error());
while($d=mysql_fetch_array($det)){
$id = mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $_GET['id']);
$det = mysqli_query($GLOBALS["___mysqli_ston"], "select * from menu where id_menu ='$id'")or die(mysqli_error($GLOBALS["___mysqli_ston"]));
while($d=mysqli_fetch_array($det)){
?>
<form action="edit_proses.php" method="post" enctype="multipart/form-data">
<table class="table">
......
......@@ -9,6 +9,6 @@
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');
?>
\ No newline at end of file
......@@ -9,7 +9,7 @@ if(isset($_GET['do_login'])){
$_SESSION['login_error'] = TRUE;
}else{
$_SESSION['user'] = TRUE;
$row = mysql_fetch_assoc($resUsr);
$row = mysqli_fetch_assoc($resUsr);
$_SESSION['id_member'] = $row['id_member'];
header("location:index.php");
}
......
......@@ -2,6 +2,6 @@
include 'koneksi.php';
$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');
?>
\ No newline at end of file
......@@ -3,5 +3,4 @@ $host="127.0.0.1";
$user="root";
$pass="";
$name="p1d3ti04_pondokedo";
$koneksi=mysql_connect($host,$user,$pass)or die("Koneksi ke database gagal!");
mysql_select_db($name,$koneksi)or die("Tidak ada database yang dipilih!");
$koneksi=($GLOBALS["___mysqli_ston"] = mysqli_connect($host, $user, $pass, $name))or die("Koneksi ke database gagal!");
......@@ -8,16 +8,17 @@ include 'common/header.php';
<?php
$per_hal = 8;
$jumlah_record = mysql_query("SELECT COUNT(*) from menu");
$jum = mysql_result($jumlah_record, 0);
$query = "SELECT COUNT(*) from menu";
$jumlah_record = mysqli_query($koneksi, $query);
$jum = mysqli_affected_rows($jumlah_record);
$halaman = ceil($jum / $per_hal);
$page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1;
$start = ($page - 1) * $per_hal;
?>
<br/>
<?php
$menu = mysql_query("select * from menu limit $start, $per_hal");
while ($b = mysql_fetch_array($menu)) {
$menu = mysqli_query($GLOBALS["___mysqli_ston"], "select * from menu limit $start, $per_hal");
while ($b = mysqli_fetch_array($menu)) {
?>
<div class="col-md-3">
......
......@@ -2,17 +2,13 @@
include 'koneksi.php';
include 'fungsi/fungsi.php';
$id = mysql_real_escape_string($_GET['id']);
$query = mysql_query("SELECT * menu WHERE id_menu= '$id'");
$q = mysql_fetch_array($query);
$id = $_GET['id'];
$id_member = get_session('id');
$id_menu = $q['id_menu'];
$tanggal = DATE_COOKIE;
$id_menu = $id;
$tanggal = date('Y-m-d');
$jumlah = $_POST['jumlah'];
mysql_query("INSERT INTO pemesanan(member_id, menu_id, tanggal, jumlah) VALUES('$id_member','$id_menu','$tanggal','$jumlah')");
header("Location: detail.php?id=".$id);
mysqli_query($koneksi, "INSERT INTO pemesanan(member_id, menu_id, tanggal, jumlah,id_pemesanan) VALUES('$id_member','$id_menu','$tanggal','$jumlah','')");
?>
\ No newline at end of file
......@@ -7,6 +7,6 @@
$image = $_FILES['gambar']['name'];
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');
?>
\ 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