Forum
Topic RSS
18:06
08/03/2011
OfflineI was trying this code to use adodb library for php. The grid doesnt show me anything.
Neither with XML or JSON.
Someone can tell me what i'm doing wrong?
<?php
include('adodb5/adodb.inc.php');
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$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
if(!$sidx) $sidx =1;
// connect to the database
$db = ADONewConnection('mysql'); # eg 'mysql' or 'postgres'
$db->debug = true;
$db->Connect('localhost', 'root', 'admin', 'jQgrid_demos');
$row = $db->GetRow("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id");
$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)
$result = $db->Execute("SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start, $limit");
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0;
while ($row = $result->fetchRow()){
$responce->rows[$i]['id']=$row[id];
$responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]);
$i++;
}
echo json_encode($responce);
?>
Most Users Ever Online: 816
Currently Online:
36 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66
Log In
Home