[help] Refresh with sound if new record found
5 replies [Last post]
blur
User offline. Last seen 2 years 16 weeks ago. Offline
Joined: 12/23/2011
Points: 2

Salam.. sy baru nak belajar cakephp ni, bolehkah tunjukan pd sy bagaimana nak keluarkan sound bila record baru wujud (refresh).. ini contoh kod sy

Controller

<?php
class PostsController extends AppController {
    public $name = 'Posts';
    public $helpers = array('Html', 'Form');
var $paginate = array(
'fields' => array('Post.id', 'Post.title','Post.created','Post.modified','Post.status'),
'limit' => 15,
'order' => array(
'Post.id' => 'DESC'
)
);

public function index() {
        #$this->set('posts', $this->Post->find('all'));
$posts = $this->Paginate('Post');
#$this->set('posts', $this->Pageinate('Post'))
$this->set(compact('posts'));
}

Index

<center><h3>Senarai Hakmilik Terkini</h3></center>
<?php
$sec
= "10";
header("Refresh: $sec;");
?>



<table>
    <tr>
        <th></th>
        <th>No. Hakmilik</th>
        <th>Tarikh</th>
<th>Diserah pada</th>
<th>Status</th>
</tr>

    <!-- Here is where we loop through our $posts array, printing out post info -->

    <?php foreach ($posts as $post): ?>

<tr>
        <td></td>
        <td>
            <?php echo $this->Html->link($post['Post']['title'],
array(
'controller' => 'posts', 'action' => 'edit', $post['Post']['id'])); ?>

        </td>
        <td><?php echo $post['Post']['created']; ?></td>
<td><?php echo $post['Post']['modified']; ?></td>
<td><?php echo $post['Post']['status']; ?></td>
</tr>
    <?php endforeach; ?>

</table>

<hr />
<p><?php
   
echo $this->Paginator->counter(array(
       
'format' => __d('cake', 'Mukasurat {:page} daripada {:pages}m/s, menunjukkan {:current} rekod daripada {:count} keseluruhannya.')
    ));
   
?>
</p>
<div class="paging">
<?php
       
echo $this->Paginator->prev('< ' . __d('cake', 'sebelum'), array(), null, array('class' => 'prev disabled'));
        echo
$this->Paginator->numbers(array('separator' => ''));
        echo
$this->Paginator->next(__d('cake', 'berikut') .' >', array(), null, array('class' => 'next disabled'));
   
?>

</div>


Harap ada yang dapat membantu..tq

rasenye dah jumpe keje yg best ^_^
sword_ffx's picture
User offline. Last seen 1 year 7 weeks ago. Offline
Joined: 06/23/2011
Points: 176

ni nak tanya code untuk keluarkan sound ke?

blur
User offline. Last seen 2 years 16 weeks ago. Offline
Joined: 12/23/2011
Points: 2

yup.. macam mesej alert bila page refresh, paparan ni dl mod admin bila user keyin data

rasenye dah jumpe keje yg best ^_^
sword_ffx's picture
User offline. Last seen 1 year 7 weeks ago. Offline
Joined: 06/23/2011
Points: 176

ni paling simple nyer

<embed src="sound.wav" autostart=true loop=false>
blur
User offline. Last seen 2 years 16 weeks ago. Offline
Joined: 12/23/2011
Points: 2

ok ni sy faham.. tapi yang saya maksudkan ni bila ada data baru baru keluar sound.. cth mcm kod ni, macamana pula dgn cakephp

<?php
while($all = mysql_fetch_array( $allResults )){
 
$countNew++;
}
if(
$_SESSION[count] < $countNew){
$_SESSION[count]= $countNew;
echo
'encode sound';
}
?>
rasenye dah jumpe keje yg best ^_^
sword_ffx's picture
User offline. Last seen 1 year 7 weeks ago. Offline
Joined: 06/23/2011
Points: 176

try sizeof() function untuk kira bilangan keseluruhan record lepas tu compare dgn session tu