<?php
class viewslide{
    var $id;
    
    function listslide(){
        $slide = mysql_query("SELECT * FROM slider ORDER BY id_slider");

        while ($s = mysql_fetch_array($slide)){
            $data[$i] = array(
                        'id' => $s[id_slider],
                        'judul' => $s[judul],
                        'gambar' => $s[gambar],
                        'keterangan' => $s[keterangan]
                     );
            
            $i++;
        }
        
        return($data);
        
    }
    
    function slide(){
        $slide = mysql_query("SELECT * FROM slider WHERE id_slider = $this->id");
        $s = mysql_fetch_array($slide);
        
        $data = array(
                        'id' => $s[id_slider],
                        'judul' => $s[judul],
                        'gambar' => $s[gambar],
                        'keterangan' => $s[keterangan]
                     );
        
        return($data);
        
    }
    
    function addslide($judul,$gambar,$keterangan){

        $tgl = date("d-m-Y");

        mysql_query("INSERT INTO slider(    judul,
                                            keterangan,
                                            gambar,
                                            dateadd,
                                            dateedit) 
                                            VALUES(
                                            '$judul',
                                            '$keterangan',
                                            '$gambar',
                                            STR_TO_DATE('$tgl','%d-%m-%Y'),
                                            STR_TO_DATE('$tgl','%d-%m-%Y'))");
    }
    
    function editslide($judul,$keterangan){

        $tgl = date("d-m-Y");
        
        mysql_query("UPDATE slider SET  judul       = '$judul',
                                        keterangan  = '$keterangan',
                                        gambar      = '$gambar',
                                        dateedit    = STR_TO_DATE('$tgl','%d-%m-%Y')
                                        WHERE
                                        id_slider     = $this->id");
    }
    
    function deleteslide(){
        mysql_query("DELETE FROM slider where id_slider = $this->id");
    }
}