<?php
class viewgaleri{
	var $id;

	function listgaleri(){
        $galeri = mysql_query("SELECT * FROM galeri ORDER BY id_galeri");

        while ($p = mysql_fetch_array($galeri)){
            $data[$i] = array(
                        'id' => $p[id_galeri],
                        'id_katgaleri' => $p[id_katgaleri],
                        'nama' => $p[nama]
                     );
            
            $i++;
        }
        
        return($data);
        
    }

    function listgalerikat($id){
        $galeri = mysql_query("SELECT * FROM galeri WHERE id_katgaleri = $id ORDER BY id_galeri");

        while ($p = mysql_fetch_array($galeri)){
            $data[$i] = array(
                        'id' => $p[id_galeri],
                        'id_katgaleri' => $p[id_katgaleri],
                        'nama' => $p[nama]
                     );
            
            $i++;
        }
        
        return($data);
        
    }

    function addgaleri($id_katgaleri,$nama){
        $tgl = date("d-m-Y");
        
        mysql_query("INSERT INTO galeri(    id_katgaleri,
                                            nama,
                                            dateadd,
                                            dateedit) 
                                            VALUES(
                                            '$id_katgaleri',
                                            '$nama',
                                            STR_TO_DATE('$tgl','%d-%m-%Y'),
                                            STR_TO_DATE('$tgl','%d-%m-%Y'))");
    }

    function deletegalerikat($id){
        mysql_query("DELETE FROM galeri where id_katgaleri = $id");
    }

    function deletegaleri(){
        mysql_query("DELETE FROM galeri where id_galeri = $this->id");
    }
}