Forum Sementara Putera.com

Bersama kita perkemaskan forum ini sementara forum asal dalam pemulihan.

Forum putera dah kembali. Masalah sudah berjaya diselesaikan. Sila lawati http://forum.putera.com/tanya


    *konpius* data filter

    Share

    kroerysher
    Ahli Baharu
    Ahli Baharu

    Gender : Female Number of posts : 4
    Age : 32
    Location : ipoh malii...
    Job/hobbies : anime..programmin...books
    Registration date : 27/03/2009

    *konpius* data filter

    Post by kroerysher on Fri Mar 27, 2009 10:15 am

    salam...

    sy dh tersangkut sikit ni...sy nak buat content filter, where user boleh filter data yang mereka nak by selecting the provided dropdown. ade tiga dropdown yang diberi

    1. bulan
    2. status aduan
    3. jenis kerosakan

    kire user boleh filter rekod yg mereka nk by choosing all of the dropdown, pilih dua, pilih salah satu and if user tak pilih apa-apa then trus tekan submit all of the record will be display..masalah sekarang ni ada prob sikit bile user nk filter by selecting only one of the dropdown and bile user tak pilih apa-apa..query dia tak jalan...dh naik juling dh mate ni nk cari error dia, or struktur if...else if yang saya buat ni tak bape betoi...saya pun tak sure dh ni...so kalau boleh nk mintak tolong kengkwn sume...ade suggestion or jln penyelesaian lain tak...


    ni structure query yg sy dh buat....kira stat dr query yang bertande problem starts till ke problem ends tu masalah...dia tak boleh ditect selection yang dibuat by user...

    Code:

    <?php
            if(isset($_POST['Submit']))
            {
          $status=$_POST['status'];
         $bulan=$_POST['bulan'];
         $jenis=$_POST['jenis'];
        
    /*if($status=="#")
    {
    echo"<script language='JavaScript'>alert('Sila buat pilihan bulan');</script>";
    echo'<meta http-equiv="refresh" content="0;URL=query.php">';
    }
    if($bulan=="#")
    {
    echo"<script language='JavaScript'>alert('Sila buat pilihan status aduan');</script>";
    echo'<meta http-equiv="refresh" content="0;URL=query.php">';
    }
    if($jenis=="#")
    {
    echo"<script language='JavaScript'>alert('Sila buat pilihan status jenis kerosakan');</script>";
    echo'<meta http-equiv="refresh" content="0;URL=query.php">';
    }*/

    if ($bulan == "semua")
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE aduan.status='$status' AND kerosakan.jenis_kerosakan='$jenis' AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if ($status == "semua")
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE (DATE_FORMAT(aduan.tarikh_aduan, '%M %Y')='$bulan' AND kerosakan.jenis_kerosakan= '$jenis') AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if ($jenis == "semua")
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE (DATE_FORMAT(aduan.tarikh_aduan, '%M %Y')='$bulan' AND aduan.status='$status') AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if (($bulan == "semua") && ($status == "semua"))    <------problem starts
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE kerosakan.jenis_kerosakan='$jenis' AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if (($status == "semua") && ($jenis == "semua"))
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE DATE_FORMAT(aduan.tarikh_aduan, '%M %Y')='$bulan' AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if (($bulan == "semua") && ($jenis == "semua"))
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE aduan.status='$status' AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if (($bulan == "semua") && ($status == "semua") && ($jenis == "semua"))
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }  <---------problem ends
    else
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE (DATE_FORMAT(aduan.tarikh_aduan, '%M %Y')='$bulan' AND aduan.status='$status' AND kerosakan.jenis_kerosakan='$jenis') AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    .................
    ?>

    li9ht
    Ahli Baharu
    Ahli Baharu

    Number of posts : 2
    Registration date : 02/03/2009

    Re: *konpius* data filter

    Post by li9ht on Fri Mar 27, 2009 3:02 pm

    mana page yg ada form drop down suma.. lagi senang tgk apa prob kalo ada 2 dua skali.. lagi pun mgkin bkn sbb page nih..mgkin sebab page yg contain form tuh..btw sbb apa letak echo tuh.. trus $q="aaaaa" pun bole kan..

    kroerysher
    Ahli Baharu
    Ahli Baharu

    Gender : Female Number of posts : 4
    Age : 32
    Location : ipoh malii...
    Job/hobbies : anime..programmin...books
    Registration date : 27/03/2009

    Re: *konpius* data filter

    Post by kroerysher on Fri Mar 27, 2009 3:56 pm

    echo tu just for testing the query je...nk tgok leh jln tak...ok ni the whole prog..sy buat dlm satu page je....

    Code:

    <form id="form1" name="form1" method="post" action="">
      <table width="396" border="0" align="center" cellpadding="2" cellspacing="2">
        <tr>
          <td width="123"><strong>Bulan</strong></td>
          <td width="10">:</td>
          <td width="263">
         <?          
        
         $result = mysql_query("SELECT DATE_FORMAT( tarikh_aduan, '%M %Y' ) AS newdate
                                  FROM aduan WHERE kolej='$kolej'
                                  GROUP BY month( tarikh_aduan )
                                  ORDER BY tarikh_aduan")
                      or die("Invalid Query: " .mysql_query());
     
    echo '<select id="bulan"  name="bulan">';
    echo '<option selected value="semua">-Sila Pilih-</option>';
    //echo '<option value="semua">Semua</option>';

     
    while ($row = mysql_fetch_assoc($result))
    {
    $va = $row['newdate'];

    echo "<option value='$va'>$va</option>";
    }
    echo '</select>';
    ?></td>
        </tr>
        <tr>
          <td><strong>Status Aduan </strong></td>
          <td>:</td>
          <td><?           $result = mysql_query("SELECT status from aduan WHERE kolej='$kolej'")
                      or die("Invalid Query: " .mysql_query());
     
    echo '<select id="status"  name="status">';
    echo '<option selected value="semua">-Sila Pilih-</option>';
    //echo '<option value="semua">Semua</option>';

     
    while ($row = mysql_fetch_assoc($result))
    {
    $va = $row['status'];

    echo "<option value='$va'>$va</option>";
    }
    echo '</select>';
    ?></td>
        </tr>
        <tr>
          <td><strong>Jenis Kerosakan </strong></td>
          <td>:</td>
          <td><?          
        
         $result = mysql_query("SELECT kerosakan.jenis_kerosakan from aduan,kerosakan WHERE aduan.kolej='$kolej' AND    aduan.no_aduan=kerosakan.no_aduan GROUP BY kerosakan.jenis_kerosakan")
          or die("Invalid Query: " .mysql_query());
     
    echo '<select id="jenis"  name="jenis">';
    echo '<option selected value="semua">-Sila Pilih-</option>';
    //echo '<option value="semua">Semua</option>';

     
    while ($row = mysql_fetch_assoc($result))
    {
    $va = $row['jenis_kerosakan'];

    echo "<option value='$va'>$va</option>";
    }
    echo '</select>';
    ?></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><input type="submit" name="Submit" value="Hantar" /></td>
        </tr>
      </table>
    </form>
                <?php
            if(isset($_POST['Submit']))
            {
          $status=$_POST['status'];
         $bulan=$_POST['bulan'];
         $jenis=$_POST['jenis'];
        
    /*if($status=="#")
    {
    echo"<script language='JavaScript'>alert('Sila buat pilihan bulan');</script>";
    echo'<meta http-equiv="refresh" content="0;URL=query.php">';
    }
    if($bulan=="#")
    {
    echo"<script language='JavaScript'>alert('Sila buat pilihan status aduan');</script>";
    echo'<meta http-equiv="refresh" content="0;URL=query.php">';
    }
    if($jenis=="#")
    {
    echo"<script language='JavaScript'>alert('Sila buat pilihan status jenis kerosakan');</script>";
    echo'<meta http-equiv="refresh" content="0;URL=query.php">';
    }*/

    if ($bulan == "semua")
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE aduan.status='$status' AND kerosakan.jenis_kerosakan='$jenis' AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if ($status == "semua")
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE (DATE_FORMAT(aduan.tarikh_aduan, '%M %Y')='$bulan' AND kerosakan.jenis_kerosakan= '$jenis') AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if ($jenis == "semua")
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE (DATE_FORMAT(aduan.tarikh_aduan, '%M %Y')='$bulan' AND aduan.status='$status') AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if (($bulan == "semua") && ($status == "semua"))
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE kerosakan.jenis_kerosakan='$jenis' AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if (($status == "semua") && ($jenis == "semua"))
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE DATE_FORMAT(aduan.tarikh_aduan, '%M %Y')='$bulan' AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if (($bulan == "semua") && ($jenis == "semua"))
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE aduan.status='$status' AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else if (($bulan == "semua") && ($status == "semua") && ($jenis == "semua"))
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }
    else
    {
    echo $qry ="SELECT * FROM aduan,kerosakan WHERE (DATE_FORMAT(aduan.tarikh_aduan, '%M %Y')='$bulan' AND aduan.status='$status' AND kerosakan.jenis_kerosakan='$jenis') AND aduan.kolej='$kolej' AND aduan.no_aduan = kerosakan.no_aduan GROUP BY kerosakan.no_aduan";
            $qid = mysql_query($qry);
    }


    $query2 ="SELECT COUNT(*) from aduan where kolej='$kolej' AND status='$status'";
    $id2 = mysql_query($query2);
    while($baris2 = mysql_fetch_array($id2)){
                      
    echo "<p align='center'><strong>Status Aduan: ".$status.  "<br>Jumlah: ". $baris2['COUNT(*)']."</strong></p><br>";
    echo "<p align='center'><strong>Jenis Kerosakan: ".$jenis.  "<br>Bulan: ". $bulan."</strong></p><br>";
    }

    ?>
    <p>&nbsp;</p>
    <table width="605" height="24" border="1" align="center" cellpadding="1" cellspacing="1">
              <tr bgcolor="#A4C9DC">
                <td width="39"><div align="center"><strong>No</strong></div></td>
                <td width="118"><div align="center"><strong>No Aduan </strong></div></td>
                <td width="199"><div align="center"><strong>Jenis Kerosakan </strong></div></td>
                <td width="137"><div align="center"><strong>No.Rumah</strong></div></td>
                <td width="84"><div align="center">&nbsp;</div></td>
              </tr>
            <?    
            while($row2 = mysql_fetch_array ($qid)){  // repeat region
          $no_aduan=$row2['no_aduan'];
            $bil++;
       ?>
              <tr>
                <td><div align="center">
                  <?=$bil;?>
                </div></td>
                <td><? echo $row2['no_aduan']; ?></td>
                <td><div align="left"><? echo $row2['jenis_kerosakan']; ?></div></td>
                <td><div align="center"><? echo $row2['no_rumah']; ?></div></td>
                <td><div align="center"><a href="papar_rekod_status.php?no_aduan=<?=$no_aduan;?>">Butiran</a></div></td>
         <? }
         }
         ?>
              </tr>
          </table>

    Kuzie
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 125
    Age : 32
    Location : eVeRyWhErE
    Registration date : 13/02/2009

    Re: *konpius* data filter

    Post by Kuzie on Sat Mar 28, 2009 2:30 am

    aku pun konfius dgn ko mana nak select kolej....ke sebelum masuk form tu org dah select kolej ke camne..???

    Kuzie
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 125
    Age : 32
    Location : eVeRyWhErE
    Registration date : 13/02/2009

    Re: *konpius* data filter

    Post by Kuzie on Sat Mar 28, 2009 3:07 am

    cuba bagi detail kat bawah:

    1) Postkan kod form yg berkaitan dgn problem ko dari submit form sampai result keluar sbb aku macam xjmpe mana nak select kolej (kalau boleh asing2 kan jgn bagi one shoot satu page)

    2) Ko bagi field apa yg ada dalam table aduan dgn table kerosakan supaya senang kiteorang nak create database Demo(kalau boleh isikan la sikit die punye record supaya gambaran output tu lebih jelas)

    3) Filter ko ni ibarat select mana2 3 listbox dan submit die akan kuar result yg kite select tu kan. Betul / Tidak

    4) Doa-doakan la kiteorang dalam putera ni boleh tolong ko..ammmiinnn...

    kroerysher
    Ahli Baharu
    Ahli Baharu

    Gender : Female Number of posts : 4
    Age : 32
    Location : ipoh malii...
    Job/hobbies : anime..programmin...books
    Registration date : 27/03/2009

    Re: *konpius* data filter

    Post by kroerysher on Sat Mar 28, 2009 5:59 pm

    kolej tu di pass by session..bile user login..dia hanya leh view data kolej yg dia jaga je..for testing lehla setkan kolej tu as kolej='KKG'

    ni field and data for table aduan

    Code:

    -- phpMyAdmin SQL Dump
    -- version 2.10.1
    -- http://www.phpmyadmin.net
    --
    -- Host: localhost
    -- Generation Time: Mar 28, 2009 at 09:55 AM
    -- Server version: 5.0.41
    -- PHP Version: 5.2.2

    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

    --
    -- Database: `aduan`
    --

    -- --------------------------------------------------------

    --
    -- Table structure for table `aduan`
    --

    CREATE TABLE `aduan` (
      `no_aduan` varchar(15) NOT NULL,
      `tarikh_aduan` date NOT NULL,
      `kolej` varchar(3) NOT NULL,
      `no_rumah` varchar(11) NOT NULL,
      `staf_bertugas` varchar(50) NOT NULL,
      `status` varchar(30) NOT NULL,
      `tindakan` varchar(500) NOT NULL,
      `tarikh_tindakan` date NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    --
    -- Dumping data for table `aduan`
    --

    INSERT INTO `aduan` VALUES ('KKA090320073057', '2009-03-20', 'KKA', 'KKA-23-5A', '', 'Dalam Proses', '', '0000-00-00');
    INSERT INTO `aduan` VALUES ('KKG090319084934', '2009-03-19', 'KKG', 'B2-A2-1B-3A', 'En Faizul B Zabari', 'Tindakan Jabatan Pembangunan', 'perlu tindakan dari jabatan pembangunan', '2009-03-23');
    INSERT INTO `aduan` VALUES ('KKF090224102525', '2009-02-24', 'KKF', 'KKF-31-5A', '', 'Dalam Proses', '', '0000-00-00');
    INSERT INTO `aduan` VALUES ('KKB090223160946', '2009-02-23', 'KKB', 'KKB-02-2C', 'En.Hafizul B Ishak', 'Selesai', 'Ganti rail baru', '2009-02-24');
    INSERT INTO `aduan` VALUES ('KKG090223161750', '2009-02-23', 'KKG', 'KKG-12-3B', 'En Faizul B Zabari', 'Selesai', 'Ganti penyidai dan bebola pam tandas', '2009-02-27');
    INSERT INTO `aduan` VALUES ('KKA090223102452', '2009-02-23', 'KKA', 'KKA-02-1A', '', 'Dalam Proses', '', '0000-00-00');
    INSERT INTO `aduan` VALUES ('KKF090223115358', '2009-02-23', 'KKF', 'KKF-31-5A', '', 'Dalam Proses', '', '0000-00-00');
    INSERT INTO `aduan` VALUES ('KKG090323153512', '2009-03-23', 'KKG', 'B2-A2-1B-3A', '', 'Dalam Proses', '', '0000-00-00');


    ni pulak for table kerosakan

    Code:

    -- phpMyAdmin SQL Dump
    -- version 2.10.1
    -- http://www.phpmyadmin.net
    --
    -- Host: localhost
    -- Generation Time: Mar 28, 2009 at 09:55 AM
    -- Server version: 5.0.41
    -- PHP Version: 5.2.2

    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

    --
    -- Database: `aduan`
    --

    -- --------------------------------------------------------

    --
    -- Table structure for table `kerosakan`
    --

    CREATE TABLE `kerosakan` (
      `no_aduan` varchar(15) NOT NULL,
      `jenis_kerosakan` varchar(15) NOT NULL,
      `butiran` varchar(300) NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    --
    -- Dumping data for table `kerosakan`
    --

    INSERT INTO `kerosakan` VALUES ('KKF090224102525', 'Perabot', 'Pintu locker pecah');
    INSERT INTO `kerosakan` VALUES ('KKB090223160946', 'Perabot', 'Rail langsir patah');
    INSERT INTO `kerosakan` VALUES ('KKF090223115358', 'Elektrik', 'Lampu bilik terbakar');
    INSERT INTO `kerosakan` VALUES ('KKG090223161750', 'Perabot', 'Penyidai kain patah');
    INSERT INTO `kerosakan` VALUES ('KKG090223161750', 'Perpaipan', 'Pam tandas rosak');
    INSERT INTO `kerosakan` VALUES ('KKA090223102452', 'Elektrik', 'Suis Rosak');
    INSERT INTO `kerosakan` VALUES ('KKG090319084934', 'Perpaipan', 'JAMBAN ROSAK');
    INSERT INTO `kerosakan` VALUES ('KKA090320073057', 'Elektrik', 'Lampu Bilik Terbakar');
    INSERT INTO `kerosakan` VALUES ('KKG090323153512', 'Elektrik', 'LAMPU BILIK TERBAKAR');
    INSERT INTO `kerosakan` VALUES ('KKG090323153512', 'Perpaipan', 'SINKI BOCOR');

    yep...rekod akan difilter bile user select mana-mana satu dari 3 listbox yang diberi tu...

    aminnnn...hope sgt korg sume leh tolong...fenin dh ni...

    Kuzie
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 125
    Age : 32
    Location : eVeRyWhErE
    Registration date : 13/02/2009

    Re: *konpius* data filter

    Post by Kuzie on Sun Mar 29, 2009 1:10 am

    Try yg ni:

    Code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>

    <form id="form1" name="form1" method="post" action="">
      <table width="396" border="0" align="center" cellpadding="2" cellspacing="2">
    <tr>   
      <td width="123"><strong>Bulan</strong></td>
          <td width="10">:</td>
          <td width="263">
    <?php         
    $result = mysql_query("SELECT DATE_FORMAT( tarikh_aduan, '%Y-%m' ) AS newdate FROM aduan WHERE kolej='$kolej' GROUP BY month( tarikh_aduan )ORDER BY tarikh_aduan") or die("Invalid Query: " .mysql_query());
                
            echo '<select id="bulan"  name="bulan">';
            echo '<option selected value="semua">-Sila Pilih-</option>';
                '<option value="semua">Semua</option>';
           
            while ($row = mysql_fetch_assoc($result))
            {
            $va = $row['newdate'];
            echo "<option value='$va'>$va</option>";
            }
            echo '</select>';
            ?>
            </td>
        </tr>
        <tr>
          <td><strong>Status Aduan </strong></td>
          <td>:</td>
          <td>
     <?php         
    $result = mysql_query("SELECT status from aduan WHERE kolej='$kolej'  GROUP BY aduan.status") or die("Invalid Query: " .mysql_query());

          echo '<select id="status"  name="status">';
          echo '<option selected value="semua">-Sila Pilih-</option>';
     
          while ($row = mysql_fetch_assoc($result))
          {
          $va = $row['status'];
          echo "<option value='$va'>$va</option>";
          }
          echo '</select>';
    ?>      
            </td>
        </tr>
        <tr>
          <td><strong>Jenis Kerosakan </strong></td>
          <td>:</td>
          <td>
         <?php         
       
    $result = mysql_query("SELECT kerosakan.jenis_kerosakan from aduan,kerosakan WHERE aduan.kolej='$kolej' AND aduan.no_aduan=kerosakan.no_aduan GROUP BY kerosakan.jenis_kerosakan")
    or die("Invalid Query: " .mysql_query());
             
          echo '<select id="jenis"  name="jenis">';
          echo '<option selected value="semua">-Sila Pilih-</option>';
     
          while ($row = mysql_fetch_assoc($result))
          {
          $va = $row['jenis_kerosakan'];
          
          echo "<option value='$va'>$va</option>";
          }
          echo '</select>';
       ?>
          </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><input type="submit" name="Submit" value="Hantar" /></td>
        </tr>
      </table>
    </form>
                <?php
    if(isset($_POST['Submit']))
    {
    $status=$_POST['status'];
    $bulan=$_POST['bulan'];
    $jenis=$_POST['jenis'];
    $kolej=$_POST['kolej'];
    $M ="%m";
    $Y ="%Y";
    $where = "Where";
    $sign = "'";
    $AND ="AND";
       
        If($kolej=='semua')
      {$Semuakolej =""; }
        else
        {$Semuakolej ="aduan.kolej='$kolej' $AND";}

        if($bulan=='semua')
      {$SemuaBulan ="";  }
        else
        {$SemuaBulan ="DATE_FORMAT(aduan.tarikh_aduan,'$Y-$M')='$bulan' $AND";}
          // {$SemuaBulan ="DATE_FORMAT(aduan.tarikh_aduan,'$Y $M')='$bulan' $AND";} 
      If($status=='semua')
      {$SemuaStatus =""; }
        else
      {$SemuaStatus ="aduan.status='$status' $AND";}
       
      If($jenis=='semua')
        { $SemuaJenis =""; }
      else
      {$SemuaJenis ="kerosakan.jenis_kerosakan='$jenis' $AND"; }
     
           
    $qry =mysql_query("SELECT * FROM aduan,kerosakan $where $SemuaBulan $SemuaStatus $SemuaJenis $Semuakolej aduan.no_aduan=kerosakan.no_aduan GROUP BY kerosakan.no_aduan");



    $query2 ="SELECT COUNT(*) from aduan where kolej='$kolej' AND status='$status'";
    $id2 = mysql_query($query2);
    while($baris2 = mysql_fetch_array($id2)){
                     
    echo "<p align='center'><strong>Status Aduan: ".$status.  "<br>Jumlah: ". $baris2['COUNT(*)']."</strong></p><br>";
    echo "<p align='center'><strong>Jenis Kerosakan: ".$jenis.  "<br>Bulan: ". $bulan."</strong></p><br>";
    }

    ?>
    <p>&nbsp;</p>
    <table width="605" height="24" border="1" align="center" cellpadding="1" cellspacing="1">
              <tr bgcolor="#A4C9DC">
                <td width="39"><div align="center"><strong>No</strong></div></td>
                <td width="118"><div align="center"><strong>No Aduan </strong></div></td>
                <td width="199"><div align="center"><strong>Jenis Kerosakan </strong></div></td>
                <td width="137"><div align="center"><strong>No.Rumah</strong></div></td>
                <td width="84"><div align="center">&nbsp;</div></td>
              </tr>
            <?php 
          $bil = 0;
         
            while($row2 = mysql_fetch_array ($qry))
          {  // repeat region
          $no_aduan=$row2['no_aduan'];
            $bil = $bil + 1;
            ?>
              <tr>
                <td><div align="center">
                  <?php echo $bil;?>
                </div></td>
                <td><?php echo $row2['no_aduan']; ?></td>
             
                <td><div align="left"><?php echo $row2['jenis_kerosakan']; ?></div></td>
                <td><div align="center"><?php echo $row2['no_rumah']; ?></div></td>
                <td><div align="center"><a href="papar_rekod_status.php?no_aduan=<?=$no_aduan;?>">Butiran</a></div></td>
        <?php }
          }
         
       
        ?>
              </tr>
          </table>


    </body>
    </html>

    kroerysher
    Ahli Baharu
    Ahli Baharu

    Gender : Female Number of posts : 4
    Age : 32
    Location : ipoh malii...
    Job/hobbies : anime..programmin...books
    Registration date : 27/03/2009

    Re: *konpius* data filter

    Post by kroerysher on Sun Mar 29, 2009 5:46 pm

    err...knape tak keluar ape pun...data dekat drop down ade...tp bila dh filter...result tak kuar pun...

    Kuzie
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 125
    Age : 32
    Location : eVeRyWhErE
    Registration date : 13/02/2009

    Re: *konpius* data filter

    Post by Kuzie on Sun Mar 29, 2009 6:35 pm

    ko nka tengok data ko slect tu ade ke x ko wat camni:

    selepas coding bawah ni...
    Code:

    If($kolej=='semua')
      {$Semuakolej =""; }
        else
        {$Semuakolej ="aduan.kolej='$kolej' $AND";}

        if($bulan=='semua')
      {$SemuaBulan ="";  }
        else
        {$SemuaBulan ="DATE_FORMAT(aduan.tarikh_aduan,'$Y-$M')='$bulan' $AND";}
          // {$SemuaBulan ="DATE_FORMAT(aduan.tarikh_aduan,'$Y $M')='$bulan' $AND";} 
      If($status=='semua')
      {$SemuaStatus =""; }
        else
      {$SemuaStatus ="aduan.status='$status' $AND";}
       
      If($jenis=='semua')
        { $SemuaJenis =""; }
      else
      {$SemuaJenis ="kerosakan.jenis_kerosakan='$jenis' $AND"; }


    ko letak coding ni....

    Code:

    echo "SELECT * FROM aduan,kerosakan $where $SemuaBulan $SemuaStatus $SemuaJenis $Semuakolej aduan.no_aduan=kerosakan.no_aduan GROUP BY kerosakan.no_aduan" ;

    ko tengok apa yg sql die xselect...yg penting $kolej tu die read ape...

    Sponsored content

    Re: *konpius* data filter

    Post by Sponsored content Today at 4:52 pm


      Current date/time is Sat Dec 10, 2016 4:52 pm