Yii Framework Forum: How To Display Database Values Into The View Page - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

How To Display Database Values Into The View Page Rate Topic: -----

#21 User is offline   Dineshkumar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 26-April 13
  • Location:Coimbatore

Posted 24 June 2013 - 07:20 AM

echo CHtml::dropDownList('UsersStatsInfo','', array(1=>'height',2=>'weight',3=>'chest'),
array(
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('usersStatsInfo/myGraph'), //url to call.

'update'=>'#td-id', //selector to update

)));
Hi,here use the Property data as shown below,


array(
'ajax' => array(
'type'=>'POST', //request type
'data'=>array('userstatus'=>$this.value()),
'url'=>CController::createUrl('usersStatsInfo/myGraph'), //url to call.

'update'=>'#td-id', //selector to update

)
In Controller:
if(isset($_POST['userstatus']))
{
$user_status = $_POST['userstatus'];//here u will receive the respective height/width based on the selection then u can exceute the query and render the page
}
With Lots of Love,
Dinesh
0

#22 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 850
  • Joined: 20-April 11
  • Location:India

Posted 24 June 2013 - 07:23 AM

i think Devendra411 cant solve his problem this way, that i said!! requirement is not clear atall!!
Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
0

#23 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 26 June 2013 - 12:59 AM

I'm getting Undefined index:id

my viewl
 <?php
                    	echo CHtml::dropDownList('id','', array(1=>'height',2=>'weight',3=>'chest',4=>'waist',5=>'hips',6=>'biceps',7=>'bmi'),
                                	array(
                                        	'ajax' => array(
                                        	'type'=>'POST', //request type
                                        	'url'=>CController::createUrl('graph'), //url to call.
                                        	'update'=>'#td_id', //selector to update
                                        	//'data'=>'js:javascript statement'
                                        	)));
                   	?>


controller

public function actionGraph() {
        	$model = new UsersStatsInfo();
        	$data=UsersStatsInfo::model()->findAll('id=:id',
              	array(':id'=>(int) $_POST['id']));

            	$data=CHtml::listData($data,'loginId','height');
            	foreach($data as $value=>$height)
            	{
                	echo CHtml::tag('option',
               	array('value'=>$value),CHtml::encode($height),true);
            	}
            	$this->render('graph', array('model'=>$model));
    	}


And my db screen shot i'm attaching below. I need to dispaly db values based on drop down.

Attached File(s)


0

#24 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 850
  • Joined: 20-April 11
  • Location:India

Posted 26 June 2013 - 01:05 AM

public function actionGraph() {
echo 'test';exit;
                $model = new UsersStatsInfo();
                $data=UsersStatsInfo::model()->findAll('id=:id',
                array(':id'=>(int) $_POST['id']));

                $data=CHtml::listData($data,'loginId','height');
                foreach($data as $value=>$height)
                {
                        echo CHtml::tag('option',
                array('value'=>$value),CHtml::encode($height),true);
                }
                $this->render('graph', array('model'=>$model));
        }

see whats happening
Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
0

#25 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 26 June 2013 - 01:07 AM

its displaying only "test"
0

#26 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 850
  • Joined: 20-April 11
  • Location:India

Posted 26 June 2013 - 04:04 AM

ok ..good.

so ajax is working fine.
echo $_POST['id'];

check it.
Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users