Tolong pilih kategori sesuai, jenis posting (diskusi atau bukan) dan sertakan tag/topik yang sesuai seperti komputer, java, php, mysql, dll. Promosi atau posting tidak pada tempatnya akan kami hapus!
- Bagi Anda yang ingin mendaftar, baca link berikut:
http://diskusiweb.com/discussion/50491/how-to-registrasi-diskusiweb-com-baca-ini-terlebih-dahulu
- Cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com
- Cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

Cara membuat tombol buy (hidden)


Comments

  • edited January 2014
    <?php
    $result = mysql_query("SELECT r.* FROM kamar r LEFT JOIN roominventory i ON(
    (i.arrival BETWEEN '$arival' AND '$departure')
    OR (i.departure BETWEEN '$arival' AND '$departure')
    OR ('$arival' BETWEEN i.arrival AND i.departure)
    OR ('$departure' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    WHERE i.roominventory_id IS NULL");
    if (mysql_num_rows($result) > 0)
    {
    while($row = mysql_fetch_array($result))
    {
    $id_type=$row['id_type'];
    $tampil = mysql_query("SELECT * FROM type_kamar where id_type='$id_type'");
    $row2 = mysql_fetch_array($tampil);
    $harga=number_format(($row2['harga']),0,",",".");
    echo '<table width="550px" border="0">';
    echo '<tr>';
    echo '<td width="150" rowspan="5">'. '<img width=150 height=105 alt="Unable to View" src="images/products/' . $row2["img"].'"/>'.'</td>';
    echo '<tr>';
    echo '<td>'.'&nbsp;Type Kamar: '.$row2['type_kamar'].'</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>'.'&nbsp;Harga: Rp. '.$harga.',00</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>'.'&nbsp;No Kamar: '.$row['no_kamar'].'</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>'.'&nbsp;Fasilitas: '.$row2['keterangan'].'</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>';
    //echo '<input name="id_kamar" type="hidden" value="' .$row["id_kamar"]. '" />';
    echo '<input type="submit" name="Submit" value="Booking" onclick="setDifference(this.form);"/>';
    echo '</td>';
    echo '</tr>';
    echo '</table>';
    echo '<br/>';
    }
    }
    else
    {
    echo '<div style="height: 400px;">';
    echo 'Maaf berdasarkan hasil pencarian tanggal yang anda inputkan kamar tidak tersedia';
    echo '</div>';
    }
    mysql_close($con);
    ?>
  • edited January 2014
    Tolong di bantu teman".. script saya yang di atas itu tombol bookingnya eror.. jadi misalkan data kamar ada 5.. data kamar yang terpilihnya cuma 1.. itu" saja.. 

    kayanya salah di bagian ini
    <input name="id_kamar" type="hidden" value="' .$row["id_kamar"]. '" />


    mohon pencerahannya teman teman .. 

  • $replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);

    maksudnya bagaimana ? :D
    karena feeling gw polanya salah
    dan feeling gw, ada cara yg lebih baik / sederhana



    itu beneran loop query di dalam loop query ?
    apa kagak bisa disederhanakan jadi 1 query doang ?

    query elo pan bisa dijadikan 1 kaya gini :

    SELECT r.* FROM kamar r
    LEFT JOIN roominventory i ON
    (
      (i.arrival BETWEEN '$arival' AND '$departure')
      OR (i.departure BETWEEN '$arival' AND '$departure')
      OR ('$arival' BETWEEN i.arrival AND i.departure)
      OR ('$departure' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    LEFT JOIN type_kamar t ON t.id_type=r.id_type
    WHERE i.roominventory_id IS NULL



    coba dah jangan model langsung eksekusi query
    $result = mysql_query('...');

    tapi tampung dulu di variable
    $sql = '...';
    $result = mysql_query($sql);

    jadi bisa diperiksa dulu querynya
    echo $sql = '...';
    $result = mysql_query($sql);

    query yg terbentuk bakal nungul di browser
    bisa di copy paste ke db gui yg dipake
    dicoba dijalankan di db gui, dilihat hasilnya bener atau salah

    kalo masalah id
    dilihat hasil di db gui, id nya sama semua atau beda-beda ?
  • $replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);

    salah itu om.. seharusnya di hapus.. hehe..

    om saya udah coba pakai

    LEFT JOIN type_kamar t ON t.id_type=r.id_type

    tapi ko ga mau muncul ya ?


    udah coba di tampung dulu

    echo $sql = '...';
    $result = mysql_query($sql);

    tapi tetep hasilnya om..


    sebenernya tombol bokingnya bisa berfungsi om kalo pake checkbox

    echo '<input name="id_kamar" type="checkbox" value="' .$row["id_kamar"]. '" />';
    echo '<input type="submit" name="Submit" value="Booking" onclick="setDifference(this.form);"/>';

    tapi kan sebenernya ini bookingnya cuma bisa 1 kamar.. kalo pake checkbox kesannya bisa pilih lebih dari 1 kamar.. mohon di bantu om.. hehe
  • bisa juga pakai ini .. tapi cuma jalan di google chrome om.. kalo di mozilla eror

    <input name="id_kamar" type="image" value="' .$row["id_kamar"]. '" src="images/reservasi.jpg" alt="Reservasi" align="middle" width="60" height="30" onclick="setDifference(this.form);" />';
  • Emang contoh designya mo kayak gimana? hehe blm kebayang maunya kayak gimana.. :D
  • edited January 2014
    https://www.dropbox.com/sc/rbf59pa7ddlxf7x/8OWrb-P7Oo
    ni om desainnya.. saya pengen hilangin checkboxnya.. jadi cukup tombol booking aja..  hehe

    tolong di bantu om
  • edited January 2014
    hasil echo $sql nya mana ?



    kalo masalah tampilan ...
    kalo gw mungkin kagak kaya gitu

    event onclick nya gw tempel di container box nya (ntah elo pake <td> atau <div>)

    kalo box nya di klik, langsung background warna box dibuat jadi lebih gelap
    + floating text dengan tulisan "booked"

    kalo di klik di box yg sama, balik ke normal

    checkbox tetep ada, tapi hidden, buat penanda box mana yg di pilih

    kira-kira kaya gini :

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">; 
    <html>
    <head>
    <style>
    .hidden {display:none;}
    .booked {position:absolute;margin-top: -43px;margin-left:115px;z-index:1000;border:1px dashed #666;padding:2px 5px;background-color:#fff;}
    .selected {background-color:#ddd;}
    </style>
    <script>
    function book(t) {
    var i=t.getElementsByTagName("INPUT");i=i[0];
    var l=t.lastChild;
    if(l.tagName=="SPAN"&&l.getAttribute("class")=="booked") {
    t.removeChild(l);
    t.setAttribute("class","");
    i.checked="";
    }
    else {
    var n=document.createElement("SPAN");
    n.innerHTML="booked";
    n.setAttribute("class","booked");
    t.appendChild(n);
    t.setAttribute("class","selected");
    i.checked="checked";
    }
    }
    </script>
    </head>
    <body>
    <form method="get">
    <table border=1 cellspacing=1 cellpadding=2 width="300">
    <tr><td onclick="book(this)"><input value="1" type="checkbox" name="book[]" class="hidden"><br><br><br></td></tr>
    <tr><td onclick="book(this)"><input value="2" type="checkbox" name="book[]" class="hidden"><br><br><br></td></tr>
    <tr><td onclick="book(this)"><input value="3" type="checkbox" name="book[]" class="hidden"><br><br><br></td></tr>
    <tr><td onclick="book(this)"><input value="4" type="checkbox" name="book[]" class="hidden"><br><br><br></td></tr>
    <tr><td onclick="book(this)"><input value="5" type="checkbox" name="book[]" class="hidden"><br><br><br></td></tr>
    </table>
    <input type=submit>
    </form>
    </body>
    </html>


    coba elo pilih sesukanya, bisa pilih lebih dari satu, dengan kombinasi semaunya
    lalu submit

    gw pake method GET biar keliatan hasil yg dipilih dan terkirim


    catatan :
    safari di tempat gw behaviour nya agak aneh, pemilihan pertama "booked" nya meleset ke atas,
    tapi kalo di "unbooked" lalu di "booked" ulang, posisinya bener
  • edited January 2014
    maap om @kurakura.. maksud saya bukan gitu.. saya ga pengen pake checkbox.. pengennya di hilangin tombol checkboxnya .. jadi di setiap tabel kamar punya 1 tombol booking .. ini kan sewa kamarnya cuma bisa 1 om setiap kali pesan..

    jadi ga usah pakai checkbox.. cuma saya bingung bikin tommbol bookingnya

    tolong di bantu om..




    setelah klik tombol booking jadi masuk dulu ke sini om
  • edited January 2014
    <?php
    session_start();
    if (empty($_SESSION['nama']) AND empty($_SESSION['email'])){
    echo "<script>window.alert('untuk melakukan reservasi, Silahkan Login dahulu');
    window.location=('login.php')</script>";
    }
    include "koneksi.php";
    $id_kamar = $_POST['id_kamar'];
    $arival = $_POST['start'];
    $departure = $_POST['end'];
    $numberofnights = $_POST['result'];
    $dewasa = $_POST['dewasa'];
    $anak = $_POST['anak'];
    $tgl_skrg = date("Y/m/d");
    $jam_skrg = date("H:i:s");
     
    $result = mysql_query("SELECT * FROM kamar, type_kamar WHERE kamar.id_type=type_kamar.id_type and id_kamar='$id_kamar'");
    while($row = mysql_fetch_array($result))
    {
    $id_type=$row['id_type'];
    $no_kamar=$row['no_kamar'];
    $type_kamar=$row['type_kamar'];
    $keterangan=$row['keterangan'];
    $harga=$row['harga'];
    $total=$harga*$numberofnights;
    }
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Reservasi Hotel</title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" media="all" />
    <link href="../css/style_login.css" rel="stylesheet" type="text/css" media="all" />
    <style>
    table {
    font: 12px/24px Verdana, Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    margin:0 auto;
    }
    h2 {
    font: 16px/30px Georgia, "Times New Roman", Times, serif;
    margin:0 auto;
    }
    </style>
    <link href="admin/src/facebox.css" media="screen" rel="stylesheet" type="text/css" />
    <script src="admin/lib/jquery.js" type="text/javascript"></script>
    <script src="admin/src/facebox.js" type="text/javascript"></script>
    <script type="text/javascript">
    jQuery(document).ready(function($) {
    $('a[rel*=facebox]').facebox({
    loadingImage : 'admin/src/loading.gif',
    closeImage : 'admin/src/closelabel.png'
    })
    })
    </script>
    <SCRIPT language=JavaScript>
    <!--
    //Accept terms & conditions script (by InsightEye www.insighteye.com)
    //Visit JavaScript Kit (http://javascriptkit.com) for this script & more.
    function checkCheckBox(f){
    if (f.agree.checked == false )
    {
    alert('pls. agree the term and condition of this hotel');
    return false;
    }else
    return true;
    }
    //-->
    </SCRIPT>
    </head>
    <?php include "menu.php"; ?>
    <body>
    <div id="container">
    <div id="content">
    <form action="tampil_info.php" method="post" onSubmit="return checkCheckBox(this)">
    <br/>
    <div align="left" style="padding-top: 7px; font-size:24px;"><h2><strong>KONFIRMASI RESERVASI</strong></h2></div>
    <div style="margin-top: 14px;">
    <table align="left" width="617" border="0">
    <input name="nama_lengkap" type="hidden" class="ed" id="nama_lengkap" value="<?php echo $_SESSION['nama'] ; ?>">
    <input name="id_member" type="hidden" class="ed" id="id_member" value="<?php echo $_SESSION['id_member'] ; ?>">
    <input name="tgl_skrg" type="hidden" class="ed" id="tgl_skrg" value="<?php echo $tgl_skrg; ?>">
    <input name="jam_skrg" type="hidden" class="ed" id="jam_skrg" value="<?php echo $jam_skrg; ?>">
    <input name="start" type="hidden" class="ed" id="start" value="<?php echo $arival; ?>">
    <input name="total" type="hidden" class="ed" id="total" value="<?php echo $total; ?>">
    <input name="type_kamar" type="hidden" class="ed" id="type_kamar" value="<?php echo $type_kamar; ?>">
    <tr><td>Tanggal Check in*</td><td><input type="text"
    value="<?php echo $arival; ?>" size="10" maxlength="30" readonly /></td></tr>
    <input name="end" type="hidden" class="ed" id="end" value="<?php echo $departure; ?>">
    <tr><td>Tanggal Check out*</td><td><input type="text"
    value="<?php echo $departure; ?>" size="10" maxlength="30" readonly /></td></tr>
    <input name="result" type="hidden" class="ed" id="result" value="<?php echo $numberofnights; ?>">
    <tr><td>Jumlah Malam*</td><td><input type="text"
    value="<?php echo $numberofnights; ?>" size="1" maxlength="3" readonly /></td></tr>
    <input name="dewasa" type="hidden" class="ed" id="dewasa" value="<?php echo $dewasa; ?>">
    <tr><td>Dewasa*</td><td><input type="text"
    value="<?php echo $dewasa; ?>" size="1" maxlength="3" readonly /></td></tr>
    <input name="anak" type="hidden" class="ed" id="anak" value="<?php echo $anak; ?>">
    <tr><td>Anak*</td><td><input type="text"
    value="<?php echo $anak; ?>" size="1" maxlength="3" readonly /></td></tr>
    <input name="id_kamar" type="hidden" class="ed" id="id_kamar" value="<?php echo $id_kamar; ?>">
    <tr><td>Type Kamar*</td><td><input type="text"
    value="<?php echo $type_kamar; ?>" size="15" maxlength="64" readonly /></td></tr>
    <input name="no_kamar" type="hidden" class="ed" id="no_kamar" value="<?php echo $no_kamar; ?>">
    <tr><td>No Kamar*</td><td><input type="text"
    value="<?php echo $no_kamar; ?>" size="4" maxlength="3" readonly /></td></tr>
    <tr><td>Fasilitas*</td><td><textarea cols="40" rows="10" readonly><?php echo $keterangan; ?>
    </textarea></td></tr>
    <input name="harga" type="hidden" class="ed" id="harga" value="<?php echo $harga; ?>">
    <tr><td>Harga*</td><td><input size="10" maxlength="3" type="text"
    value="<?php echo $harga; ?>" readonly /></td></tr>
    <tr><td>Total*</td><td><input size="10" maxlength="3" type="text"
    value="<?php echo $total; ?>" readonly /></td></tr>
    <tr><td colspan="2">
    <small>saya setuju dengan <a rel="facebox" href="terms_condition.php">syarat & ketentuan</a> reservasi hotel</small></label>
    <input type="checkbox" value="0" name="agree">
    <input type="submit" value="Setuju">
    <input type="button" value="Batal" onClick="document.location.href='reservasi.php';">
    </form></td></tr>
    </table>
    <br/><br/>
    </div>
    </div>
    <?php
    include "footer.php";
    ?>
    </body>
    </html>
  • itu lebih gampang lagi :D

    <table border=1 cellspacing=1 cellpadding=2 width="300">
      <tr><td onclick="location.href='?book=1'"><br><br><br></td></tr>
      <tr><td onclick="location.href='?book=2'"><br><br><br></td></tr>
      <tr><td onclick="location.href='?book=3'"><br><br><br></td></tr>
      <tr><td onclick="location.href='?book=4'"><br><br><br></td></tr>
      <tr><td onclick="location.href='?book=5'"><br><br><br></td></tr>
    </table>

    coba aja elo klik,
    elo perhatikan url nya
  • kalo gitu data ini ga ke post om
    <input name="start" type="hidden" value="<?php echo $arival; ?>" />
    <input name="end" type="hidden" value="<?php echo $departure; ?>" />
    <input name="result" type="hidden" value= "<?php echo $numberofnights; ?>"/>
    <input name="dewasa" type="hidden" value= "<?php echo $dewasa; ?>"/>
    <input name="anak" type="hidden" value= "<?php echo $anak; ?>"/>
  • coba jalan berpikirnya diperbaiki ...

    begini,
    form itu bisa fake / palsu
    isiannya bisa dipaksa dimanipulasi oleh user
    meskipun sudah di hidden / readonly

    jadi, value yg dikirim dari form dibatasi seminimal mungkin memang value yg harus dikirim
    sementara value lain yg sebenernya di dapat dari database, session, konstanta ... sebaiknya ambil ulang dari tempat yg sama

    dan gw liat, value yg elo sebut itu semua dari halaman sebelumnya
    yg menurut gw sebaiknya bukan di munculkan ulang di form, tapi sudah di simpan di session utk dipake ulang
  • edited January 2014
    oh.. iya om.. menang data"nya dari halaman sebelumnya.. pertama kan user input dulu data tgl baru pilih kamar... oke om.. saya mau coba pake session ( belajar dulu ) .. hehe




  • Setelah submit tanggal input pertama di buat session;

    misalnya saat select checkin & check out select database, hasil querynya itu simpan di session.
    contoh dari pemanggilan sql di atas :
    $tampil = mysql_query("SELECT * FROM type_kamar where id_type='$id_type'");
    $row2 = mysql_fetch_array($tampil);
    $_SESSION['jenis_kamar']=$row2['type_kamar'];
    $_SESSION['nokmr']=$row['no_kamar'];
    DST...

    Aq juga masih pemula.. :)

  • sudah bisa kayaknya om kalo pake session tombol bookingnya di rubah ga pake checkbox.. hehe

    trus tapi ko page saya yang pilih kamarnya kalo di back atau pakai

    <input type=button class='cButton' value=Batal onclick=history.go(-1)>

    selalu nout foud ya ?

    Document Expired

    This document is no longer available.

    The requested document is not available in Firefox's cache.

        As a security precaution, Firefox does not automatically re-request sensitive documents.
        Click Try Again to re-request the document from the website.




    kalo di refresh 1 X baru muncul lagi...
  • jangan dibiasakan dah mas, redirect pake history
    karena value nya kagak bisa dipastikan
    bisa nyebrang ke website lain

    mending redirect ke url yg pasti saja

    toh halaman pilihan kamarnya punya url yg pasti
    isian dari form sebelumnya sudah tersimpan di session
    jadi kagak masalah kalo redirect ke url halaman pilihan kamar langsung

    butuh modifikasi sedikit sih urusan value $_POST nya
    mungkin kaya begini :

    if(isset($_POST['id_kamar'],$_POST['start'],$_POST['end'],$_POST['result'],$_POST['dewasa'],$_POST['anak'])) {
      $_SESSION['id_kamar'] = $_POST['id_kamar'];
      $_SESSION['arival'] = $_POST['start'];
      $_SESSION['departure'] = $_POST['end'];
      $_SESSION['numberofnights'] = $_POST['result'];   
      $_SESSION['dewasa'] = $_POST['dewasa'];
      $_SESSION['anak'] = $_POST['anak'];
      $_SESSION['tgl_skrg'] = date("Y/m/d");
      $_SESSION['jam_skrg'] = date("H:i:s");   
    }

    jadi hanya jika $_POST ada value nya, $_SESSION di assign ulang value nya
    tapi kalo $_POST kagak ada isinya (misal dari redirect yg dimaksud di atas), $_SESSION tetep pake value yg lama

    gitu aja
  • sip om saya coba.. makasih om
  • edited January 2014
    om.. ini sqlnya masih belum bisa manggil data type kamarnya om..
    SELECT r.* FROM kamar r
    LEFT JOIN roominventory i ON
    (
    (i.arrival BETWEEN '$arival' AND '$departure')
    OR (i.departure BETWEEN '$arival' AND '$departure')
    OR ('$arival' BETWEEN i.arrival AND i.departure)
    OR ('$departure' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    LEFT JOIN type_kamar t ON t.id_type=r.id_type
    WHERE i.roominventory_id IS NULL


    tolong di bantu om.. hehe
  • LEFT JOIN type_kamar t ON t.id_type=r.id_type
  • edited January 2014
    script nya kaya apa ?
    struktur table nya kaya apa ?
  • edited January 2014
    <?php
    $result = mysql_query("SELECT r.* FROM kamar r LEFT JOIN roominventory i ON(
    (i.arrival BETWEEN '$arival' AND '$departure')
    OR (i.departure BETWEEN '$arival' AND '$departure')
    OR ('$arival' BETWEEN i.arrival AND i.departure)
    OR ('$departure' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    LEFT JOIN type_kamar t ON t.id_type=r.id_type
    WHERE i.roominventory_id IS NULL");
    IF (mysql_num_rows($result) > 0)
    {
    while($row = mysql_fetch_array($result))
    {
     
    $harga=number_format(($row2['harga']),0,",",".");
    echo '<form action="tampil_booking.php" method="POST">';
    echo '<table width="550px" border="0">';
    echo '<tr>';
    echo '<td width="150" rowspan="5">'. '<img width=150 height=105 alt="Unable to View" src="images/products/' . $row["img"].'"/>'.'</td>';
    echo '<tr>';
    echo '<td>'.'&nbsp;Type Kamar: '.$row['type_kamar'].'</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>'.'&nbsp;Harga: Rp. '.$harga.',00</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>'.'&nbsp;No Kamar: '.$row['no_kamar'].'</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>'.'&nbsp;Fasilitas: '.$row['keterangan'].'</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>';
    echo '<input type="hidden" name="id_kamar" value='.$row['id_kamar'].'>';
    echo '<input type="hidden" name="jml" value="1" size="2" \>';
    echo '<input type="submit" value="Booking" name="submit" \>';
    echo '</form>';
    echo '</td>';
    echo '</tr>';
    echo '</table>';
    echo '<br/>';
    }
     
    }
    ELSE
    {
    echo '<div style="height: 400px;">';
    echo 'Maaf berdasarkan hasil pencarian tanggal yang anda inputkan kamar tidak tersedia';
    echo '</div>';
    }
    ?>
  •  
    --tabel kamar--
     
    CREATE TABLE IF NOT EXISTS `kamar` (
    `id_kamar` CHAR(4) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `id_type` CHAR(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `no_kamar` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `status_kamar` enum('Kosong','Terisi') CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT 'Kosong',
    PRIMARY KEY (`id_kamar`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
     
     
    --tabel tipe kamar--
     
    CREATE TABLE IF NOT EXISTS `type_kamar` (
    `id_type` CHAR(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `img` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `type_kamar` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `keterangan` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `harga` INT(11) NOT NULL,
    PRIMARY KEY (`id_type`),
    UNIQUE KEY `img` (`img`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;


  • data yang tabel type kamarnya ga ke panggil om..
  • $result = mysql_query("SELECT r.* FROM kamar r LEFT JOIN roominventory i ON(
    (i.arrival BETWEEN '$arival' AND '$departure')
    OR (i.departure BETWEEN '$arival' AND '$departure')
    OR ('$arival' BETWEEN i.arrival AND i.departure)
    OR ('$departure' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    LEFT JOIN type_kamar t ON t.id_type=r.id_type
    WHERE i.roominventory_id IS NULL");

    coba itu elo pisah dulu, jangan langsung di eksekusi ...

    echo $sql = "SELECT r.* FROM kamar r LEFT JOIN roominventory i ON(
    (i.arrival BETWEEN '$arival' AND '$departure')
    OR (i.departure BETWEEN '$arival' AND '$departure')
    OR ('$arival' BETWEEN i.arrival AND i.departure)
    OR ('$departure' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    LEFT JOIN type_kamar t ON t.id_type=r.id_type
    WHERE i.roominventory_id IS NULL";
    $result = mysql_query($sql);

    biar keliatan query string yg dihasilkan ...

    posting kemari

  • query yang di hasilkan maksudnya ini bukan om ?


    SELECT r.* FROM kamar r LEFT JOIN roominventory i ON(
    (i.arrival BETWEEN '2014/02/01' AND '2014/02/02')
    OR (i.departure BETWEEN '2014/02/01' AND '2014/02/02')
    OR ('2014/02/01' BETWEEN i.arrival AND i.departure)
    OR ('2014/02/02' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    LEFT JOIN type_kamar t ON t.id_type=r.id_type
    WHERE i.roominventory_id IS NULL
  • edited January 2014
    sekarang coba elo jalankan dulu query ini langsung di db gui yg elo pake :

    SELECT r.*
    FROM kamar r
    LEFT JOIN roominventory i ON(
    (i.arrival BETWEEN '2014/02/01' AND '2014/02/02')
    OR (i.departure BETWEEN '2014/02/01' AND '2014/02/02')
    OR ('2014/02/01' BETWEEN i.arrival AND i.departure)
    OR ('2014/02/02' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    WHERE i.roominventory_id IS NULL

    hasil nya apa ?

    posting kemari hasilnya
  • ini om hasilnya

    SELECT r.*
    FROM kamar r
    LEFT JOIN roominventory i ON(
    (i.arrival BETWEEN '2014/02/01' AND '2014/02/05')
    OR (i.departure BETWEEN '2014/02/01' AND '2014/02/05')
    OR ('2014/02/01' BETWEEN i.arrival AND i.departure)
    OR ('2014/02/05' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    WHERE i.roominventory_id IS NULL
  • hadoh ...
    "... sekarang coba elo jalankan dulu query ini langsung di db gui yg elo pake ..."
  • edited January 2014
    hehe.. maap om saya kurang ngerti magsudnya db gui..

    gini om hasilnya

    SQL result


    Host: localhost

    Database: tugas

    Generation Time: Jan 31, 2014 at 09:56 PM

    Generated by: phpMyAdmin 3.1.3.1 / MySQL 5.1.33-community

    SQL query: SELECT r.*
    FROM kamar r
    LEFT JOIN roominventory i ON(
    (i.arrival BETWEEN '2014/02/01' AND '2014/02/05')
    OR (i.departure BETWEEN '2014/02/01' AND '2014/02/05')
    OR ('2014/02/01' BETWEEN i.arrival AND i.departure)
    OR ('2014/02/05' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    WHERE i.roominventory_id IS NULL
    LIMIT 0, 30 ; 

    --hasil--


    "K006","T4","113","Kosong"
    "K007","T4","114","Kosong"

  • yang keluar data dari table kamar om.. sudah bener..
  • edited January 2014
    gw cuma butuh ini nya mas ...

    "K006","T4","113","Kosong"
    "K007","T4","114","Kosong"

    hasilnya bener cuma 2 ya ?

    sekarang, coba jalankan query ini di db gui elo :

    SELECT t.*
    FROM type_kamar t
    WHERE t.id_type="T4";

    hasilnya apa ?

    lalu coba ini di db gui :

    SELECT r.*,t.img,t.type_kamar,t.keterangan,t.harga
    FROM kamar r
    LEFT JOIN roominventory i ON(
    (i.arrival BETWEEN '2014/02/01' AND '2014/02/05')
    OR (i.departure BETWEEN '2014/02/01' AND '2014/02/05')
    OR ('2014/02/01' BETWEEN i.arrival AND i.departure)
    OR ('2014/02/05' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    LEFT JOIN type_kamar t ON t.id_type=r.id_type
    WHERE i.roominventory_id IS NULL

    hasilnya apa ?
  • kalo yang

    SELECT t.*
    FROM type_kamar t
    WHERE t.id_type="T4";

    kepanggil data

    'T4', 'suite.jpg', 'Suite', 'Tempat tidur besar + TV', 160000


    kalo..

    SELECT r.*,t.img,t.type_kamar,t.keterangan,t.harga
    FROM kamar r
    LEFT JOIN roominventory i ON(
    (i.arrival BETWEEN '2014/02/01' AND '2014/02/05')
    OR (i.departure BETWEEN '2014/02/01' AND '2014/02/05')
    OR ('2014/02/01' BETWEEN i.arrival AND i.departure)
    OR ('2014/02/05' BETWEEN i.arrival AND i.departure)
    )
    AND i.id_kamar=r.id_kamar
    LEFT JOIN type_kamar t ON t.id_type=r.id_type
    WHERE i.roominventory_id IS NULL


    kepanggil semua data kamar sama type kamarnya .. sip om @kurakura..

    makasih.. hehe





Sign In or Register to comment.