<?php
class viewfront{
	var $id;

	function frontpage1(){
		$frontpage = mysql_query("SELECT * FROM front_page WHERE id_fp = 1");
        $fp = mysql_fetch_array($frontpage);
        
        $data = array(
                        'judul' => $fp[judul],
                        'keterangan' => $fp[keterangan]
                     );
        
        return($data);
	}

    function editfrontpage1($judul,$keterangan){

        mysql_query("UPDATE front_page SET  judul           = '$judul',
                                            keterangan      = '$keterangan',
                                            dateedit        =  STR_TO_DATE('$tgl','%d-%m-%Y')
                                            WHERE 
                                            id_fp           = 1");
    }

	function frontpage2(){
		$frontpage = mysql_query("SELECT * FROM front_page WHERE id_fp = 2");
        $fp = mysql_fetch_array($frontpage);
        
        $data = array(
                        'judul' => $fp[judul],
                        'keterangan' => $fp[keterangan]
                     );
        
        return($data);
	}

	function listfrontpage2(){
		$frontpage = mysql_query("SELECT * FROM list_frontpage WHERE id_fp = 2");

		while ($fp = mysql_fetch_array($frontpage)){
            $data[$i] = array(
                        'id' => $fp[id_listfp],
                        'judul' => $fp[judul],
                        'keterangan' => $fp[keterangan],
                        'gambar' => $fp[gambar]
                     );
            
            $i++;
        }
        
        return($data);
	}

    function addlistfrontpage2($judul,$keterangan,$gambar){
        $tgl = date("d-m-Y");
        
        mysql_query("INSERT INTO list_frontpage(    idfp,
                                                    judul,
                                                    keterangan,
                                                    gambar,
                                                    dateadd,
                                                    dateedit) 
                                                    VALUES(
                                                    2,
                                                    '$judul',
                                                    '$keterangan',
                                                    '$gambar',
                                                    STR_TO_DATE('$tgl','%d-%m-%Y'),
                                                    STR_TO_DATE('$tgl','%d-%m-%Y'))");
    }

	function frontpage3(){
		$frontpage = mysql_query("SELECT * FROM front_page WHERE id_fp = 3");
        $fp = mysql_fetch_array($frontpage);
        
        $data = array(
                        'judul' => $fp[judul],
                        'keterangan' => $fp[keterangan]
                     );
        
        return($data);
	}

	function listfrontpage3(){
		$frontpage = mysql_query("SELECT * FROM list_frontpage WHERE id_fp = 3");

		while ($fp = mysql_fetch_array($frontpage)){
            $data[$i] = array(
                        'id' => $fp[id_listfp],
                        'judul' => $fp[judul],
                        'gambar' => $fp[gambar]
                     );
            
            $i++;
        }
        
        return($data);
	}

    function addlistfrontpage3($judul,$gambar){
        $tgl = date("d-m-Y");
        
        mysql_query("INSERT INTO list_frontpage(    idfp,
                                                    judul,
                                                    gambar,
                                                    dateadd,
                                                    dateedit) 
                                                    VALUES(
                                                    3,
                                                    '$judul',
                                                    '$gambar',
                                                    STR_TO_DATE('$tgl','%d-%m-%Y'),
                                                    STR_TO_DATE('$tgl','%d-%m-%Y'))");
    }

	function frontpage4(){
		$frontpage = mysql_query("SELECT * FROM front_page WHERE id_fp = 4");
        $fp = mysql_fetch_array($frontpage);
        
        $data = array(
                        'judul' => $fp[judul],
                        'keterangan' => $fp[keterangan]
                     );
        
        return($data);
	}

	function listfrontpage4(){
		$frontpage = mysql_query("SELECT * FROM list_frontpage WHERE id_fp = 4");

		while ($fp = mysql_fetch_array($frontpage)){
            $data[$i] = array(
                        'id' => $fp[id_listfp],
                        'judul' => $fp[judul],
                        'keterangan' => $fp[keterangan],
                        'list1' => $fp[list1],
                        'list2' => $fp[list2],
                        'list3' => $fp[list3],
                        'harga' => $fp[harga]
                     );
            
            $i++;
        }
        
        return($data);
	}

    function editfrontpage4($keterangan){

        mysql_query("UPDATE front_page SET  keterangan      = '$keterangan',
                                            dateedit        =  STR_TO_DATE('$tgl','%d-%m-%Y')
                                            WHERE 
                                            id_fp           = 4");
    }

    function addlistfrontpage4($judul,$keterangan,$list1,$list2,$list3,$harga){
        $tgl = date("d-m-Y");
        
        mysql_query("INSERT INTO list_frontpage(    idfp,
                                                    judul,
                                                    keterangan,
                                                    list1,
                                                    list2,
                                                    list3,
                                                    harga,
                                                    dateadd,
                                                    dateedit) 
                                                    VALUES(
                                                    4,
                                                    '$judul',
                                                    '$keterangan',
                                                    '$list1',
                                                    '$list2',
                                                    '$list3',
                                                    '$harga',
                                                    STR_TO_DATE('$tgl','%d-%m-%Y'),
                                                    STR_TO_DATE('$tgl','%d-%m-%Y'))");
    }

	function frontpage5(){
		$frontpage = mysql_query("SELECT * FROM front_page WHERE id_fp = 5");
        $fp = mysql_fetch_array($frontpage);
        
        $data = array(
                        'judul' => $fp[judul],
                        'keterangan' => $fp[keterangan]
                     );
        
        return($data);
	}

    function delete($id){
        mysql_query("DELETE FROM list_frontpage where id_listfp = $id");
    }
}