Hi, i need to display my db values in the view page. And My Database is...
ANd my view page is like this......
And My controller is like this..........
CREATE TABLE IF NOT EXISTS `users_stats_info` ( `id` int(11) NOT NULL AUTO_INCREMENT, `loginId` int(11) NOT NULL, `height` float DEFAULT NULL, `weight` float DEFAULT NULL, `chest` float DEFAULT NULL, `waist` float DEFAULT NULL, `hips` float DEFAULT NULL, `biceps` float DEFAULT NULL, `bmi` varchar(50) DEFAULT NULL, `createrId` int(11) DEFAULT NULL, `CreatedDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `updaterId` int(11) DEFAULT NULL, `updatedDate` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `userid` (`loginId`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
ANd my view page is like this......
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<!-------------------------------------------------Script for onchange------------------------------------------------------------------>
<script type="text/javascript">
function myfunction(v){
alert(v);
$.ajax({
url: '<?php echo Yii::app()->createAbsoluteUrl("usersStatsInfo/graph"); ?>',
type: 'POST',
// async: false,
data: 'ans='+v ,
success: function(res)
{
alert(res);
alert("inside success");
}
});
}
</script>
</head>
<body>
<table border="0">
<tr>
<td align="left" valign="middle" width="15%" class="fields">
<select name="bodyStats" title="Select Stats" onchange="myfunction(this.value)">
<option value="56">Weight</option>
<option value="60">height</option>
<option value="bmi">BMI</option>
<option value="chest">Chest</option>
<option value="waist">Waist</option>
<option value="hips">Hips</option>
<option value="biceps">Biceps</option>
</select>
</td>
</tr></table>
</body>
</html>
And My controller is like this..........
public function actionMyGraph() {
$model = new UsersStatsInfo();
if(Yii::app()->request->isAjaxRequest) {
if(isset ($_POST['ans'])) {
$result = $_POST['ans'];
echo $result;
//$this->render('myGraph', array('model'=>$model, false, true));
}
}
$this->render('myGraph',array('model'=>$model));
}