Daftar dan Belajar Sekarang!

Notifikasi suara saat ada data baru yang masuk

foto MRifai
18 Kontribusi 0 Coto
2 bulan yang lalu
Ane pengin saat user berhasil create data nanti bakalan muter audio caranya gimana ya gan..? ane pake framework codeigniter CONTROLLER
public function postcomment()
	{
		$this->form_validation->set_rules('comment','Commment','required');
		$this->form_validation->set_rules('subject','Subject','required');
		if($this->form_validation->run() != false){
		$comment = $this->input->post('comment');
		$subject = $this->input->post('subject');

		$data = array(
			'comment' => $comment,
			'subject' => $subject
			);
		$this->m_comment->input_data($data,'comments');
		$_SESSION['pesan'] = 'Data berhasil di kirim';
		redirect('home/contact');
		
		}else{
			$this->load->view('web/contact',$data);
		}
	}
MODEL
function update_data($where,$data,$table){
		$this->db->where($where);
		$this->db->update($table,$data);
	}
AUDIONYA
<audio id="myAudio">
    <source src="<?php echo base_url(); ?>assets/AdminLTE/sound/line_messenger.mp3" type="audio/mpeg">
      Your browser does not support the audio element.
    </audio>
NOTIFIKASI NAVBAR
<a class="nav-link" id="notification-icon" data-toggle="dropdown" href="#">
              <i class="far fa-comments"></i>
              <span id="notif-count" class="badge badge-danger navbar-badge"><?php if($count>0) { echo $count; } ?></span>
              <div id="notification-latest"></div>
            </a>

Jawaban
foto rikicmd
2 Kontribusi 0 Coto
2 bulan yang lalu
Bisa pakai library javascript namanya Howler. Tapi waktu klik button create harus pakai ajax, biar halamannya tidak direload.
  • ok terimakasih gan saya coba - MRifai


Login untuk diksusi di forum sekolah koding