Dear All
Please refer
JQuery code
- $('#relationwithmaratheid').change( function () {
- alert($('#relationwithmaratheid').val()); // display the id when drop down changes which is correctly displayed
-
- $.getJSON("relationwithmarathejsonfill.php", {id: $('#relationwithmaratheid').val()}, function(data){
- $('#sondiv').text(data['son']);
- $('#daughterdiv').text(data['daughter']);
- $('#husbanddiv').text(data['husband']);
-
- });
-
- });
The div's
- <div id="sondiv">Content for id "sondiv" Goes Here</div>
- <div id="daughterdiv">Content for id "daughterdiv" Goes Here</div>
- <div id="husbanddiv">Content for id "Husbanddiv" Goes Here</div>
relationwithmarathejsonfill.php
- <?php
- //relationwithmarathejsonfill.php
- session_start();
-
- include_once("includes/dbconnect.php");
- include_once("includes/config.inc.php");
- $id=$_REQUEST['id'];
- echo $id;
- $sql = mysql_query("select * from relationwithmarathe where id=2");
- echo mysql_num_rows($sql);
- if(mysql_num_rows($sql))
- {
- $data = mysql_fetch_array($sql);
- echo json_encode($data);
-
- }
- ?>
if we type
we can see valued like
51{"0":"2","id":"2","1":"0","status":"0","2":"1","son":"1","3":"0","husband":"0","4":"0","daughter":"0","5":"0","surname":"0","6":"1","gender":"1","7":"0","self":"0","8":"0","srno":"0","9":"Son Marathe Mother","name":"Son Marathe Mother","10":null,"brief":null,"11":null,"detail":null,"12":null,"actualimage":null,"13":null,"tinyimage":null,"14":null,"smallimage":null,"15":null,"bigimage":null,"16":null,"smallwimage":null,"17":null,"bigwimage":null,"18":"2015-06-10 04:58:18","dttime":"2015-06-10 04:58:18"}
but the div's are not populated
Database Table structure
Table structure for table `relationwithmarathe`
--
CREATE TABLE IF NOT EXISTS `relationwithmarathe` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`status` tinyint(1) DEFAULT '0',
`son` tinyint(2) DEFAULT '0',
`husband` int(11) DEFAULT '0',
`daughter` tinyint(2) DEFAULT '0',
`surname` tinyint(2) DEFAULT '0',
`gender` tinyint(3) DEFAULT '0',
`self` tinyint(2) DEFAULT '0',
`srno` int(13) DEFAULT '0',
`name` varchar(255) DEFAULT NULL,
`brief` text,
`detail` text,
`actualimage` varchar(255) DEFAULT NULL,
`tinyimage` varchar(255) DEFAULT NULL,
`smallimage` varchar(255) DEFAULT NULL,
`bigimage` varchar(255) DEFAULT NULL,
`smallwimage` varchar(255) DEFAULT NULL,
`bigwimage` varchar(255) DEFAULT NULL,
`dttime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;