Ajax Auto Refresh Div

Hi I’m new to Yii and I had a problem with my code.

This is my views file Display.php


var auto_refresh = setInterval(




}, 5000);


    <div id="myDIV" >

        <div>Latest Count: <?php echo $db[0]['TotalCount'];?></div>

        <div>Latest EmpID: <?php echo $db[0]['EmpID'];?></div>



This is where my models file DailyResultAction.php

<?php if ( ! defined('YII_PATH')) exit('No direct script access allowed');


class  DailyResultAction{



    public function  GETResultQuery(){

        $mysql = new TestMYSQL();

        $sqlstr = "Select *,(select count(*) from myTable) as TotalCount from ".MainDB.".myTable where EmpID=(select max(EmpID) from ".MainDB.".myTable)";


        $result = $mysql->MyQueryAll(MainDB,$sqlstr);


        return $result;              



This is my controller file MyController.php


class MyController extends Controller



    public function ControllerResult()






            $Display= new DailyResultAction();

            $model =  $Display->GETResultQuery();

            $this -> render('Display',array('db'=>$model));






The auto refresh doesn’t work… I wonder is my mistaken in assign


please help

I’m not sure what you are trying to do, but why are you fading your controller. I don’t think you can call the controller like that.

I’m guessing your trying to bring up some data from a DB. I would suggest you make a function actionPageName inside your controller. Make the page inside your view and then call that.

If you explain a little more it will also help others. :)


Hi thanks for your reply and sorry for my English. :(

I like to refresh my div automatically without refreshing the whole page.

The time interval is 5 seconds and when it refreshing i want to show the latest count of record and empID in database.