Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Json Data not show in table
07/07/2012
11:23
Avatar
saravanan
New Member
Members
Forum Posts: 1
Member Since:
07/07/2012
sp_UserOfflineSmall Offline

Please help me.

<script>

var mygrid = jQuery(document).ready(function (){

       //var getUrl = 'network_javascript/getGridData.php?state=<?php echo $state; ?>&city=<?php echo $city; ?>&area=<?php echo $area; ?>&hospital=<?php echo $hospital; ?>';
    
       jQuery("#list").jqGrid({

         // url:'<?php echo _PATH_ROOT1; ?>/network_javascript/getGridData.php?state=<?php echo $state; ?>&city=<?php echo $city; ?>&area=<?php echo $area; ?>&hospital=<?php echo $hospital; ?>',
    
             url:'network_javascript/getGridData.php?state=<?php echo $state; ?>&city=<?php echo $city; ?>&area=<?php echo $area; ?>&hospital=<?php echo $hospital; ?>',
         jsonReader: { root: "rows" },    
         //url: getUrl,
         datatype: "json",
         colNames:['Hospital Name', 'Telephone Number', ''],
            colModel:[
          {name:'HospitalName',index:'HospitalName', width:'300px', height:"auto"},
                {name:'CONTACTNO',index:'CONTACTNO', width:'190px', align:'right', sortable:false},
                {name:'details',index:'details', width:'100px', sortable:false, align:'center'}
            ],
            rowNum:10,
            //rowList:[20,50,100],
            autowidth: true,
         //shrinkToFit: false,
            autoheight: true,
            pager: jQuery('#pager'),
            sortname: 'HospitalName',
            viewrecords: true,
            pgbuttons: true,
            pginput: true,
            sortorder: "asc",
            caption:"Network Hospital - <?php echo $rows;?> hospitals found",
             
            loadComplete: function(){
         alert('test');
        // alert( '<?php echo dirname(__FILE__); ?>' );
        // alert( '<?php echo _PATH_ROOT1; ?>' );    
        // alert('network_javascript/getGridData.php?state=<?php echo $state; ?>&city=<?php echo $city; ?>&area=<?php echo $area; ?>&hospital=<?php echo $hospital; ?>');    
          
          var ids = jQuery("#list").getDataIDs();
          
                for(var i=0;i<ids.length;i++){
            var cl = ids[i];
            viewDetails = "<a href='network_javascript/viewDetails.php?id="+cl+"&height=300&width=300&inlineId=myOnPageContent' class='thickbox' title='Hospital Details'>view details</a>";
            jQuery("#list").setRowData(ids[i],{details:viewDetails});
          }
                tb_init('a.thickbox, area.thickbox, input.thickbox');
          }
       });
     });

</script>

File : getGridData.php

<?php
/*
 * @author Rohit D'Souza <rohit.dsouza@interactiveavenues.com>
 *
 */

// connect to the database
//include_once 'db.conf.php';

include_once("../admin/PathConfig.php");
include_once(_PATH_ROOT."config.php");
include_once(_PATH_LIBS."loader.php");    

  

/*
$page = $_GET['page']; // get the requested page
$limit = $_GET['rows']; // get how many rows we want to have into the grid
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction
*/

$page = ((!empty($_REQUEST['page']))? ($_REQUEST['page']) : "-1" ); // get the requested page
$limit = ((!empty($_REQUEST['rows']))? ($_REQUEST['rows']) : "-1" ); // get how many rows we want to have into the grid
$sidx = ((!empty($_REQUEST['sidx']))? ($_REQUEST['sidx']) : "-1" ); // get index row - i.e. user click to sort
$sord = ((!empty($_REQUEST['sord']))? ($_REQUEST['sord']) : "" ); // get the direction

if(!$sidx) $sidx ="1";

// retrieve search form params

$state = (!empty($_REQUEST['state']) ? $_REQUEST['state'] : "-1" );
$city = (!empty($_REQUEST['city']) ? $_REQUEST['city'] : "-1" );
$area = (!empty($_REQUEST['area']) ? $_REQUEST['area'] : "-1" );
$hospital = (!empty($_REQUEST['hospital']) ? $_REQUEST['hospital'] : "" );

// formation of where clause
$whereClause = " where 1=1 and CHECK_HOSPITAL = 'NH'";
if(isset($state) && $state!='-1' && $state!='')
    $whereClause .= " and STATE='$state' ";
if(isset($city) && $city!='-1' && $city!='')
    $whereClause .= " and City='$city' ";
if(isset($area) && $area!='-1' && $area!='')
    $whereClause .= " and AREA='$area' ";
if(isset($hospital) && $hospital!='')
    $whereClause .= " and HospitalName like '$hospital%' ";
    

// No. of Rows
$query = "SELECT COUNT(*) AS count FROM network_hospital ".$whereClause;
$result = mysql_query($query);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];

if( $count >"0" ) {
    $total_pages = ceil($count/$limit);
} else {
    $total_pages = "0";
}
if ($page > $total_pages) $page=$total_pages;

$start = $limit*$page - $limit; // do not put $limit*($page - 1)
if ($start < "0" ) $start = "0";

// Data for Grid
$query = "SELECT * FROM network_hospital ".$whereClause;
$query .= " ORDER BY $sidx $sord LIMIT $start, $limit";
$result = mysql_query( $query ) or die("Couldn't execute query - $query <br>\n".mysql_error());

// JSON data
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;

$i= "0";

while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {

    $responce->rows[$i]['id']=$row['id'];

    $responce->rows[$i]['cell']= array($row['HospitalName'],$row['CONTACTNO'],'');

    $i++;
}
echo json_encode($responce);

?>

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
33 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information