Forum


15:34

18/04/2010

Hi i am kinda new to all this. Wanted to implement jqgrid …. I followed the documentation on /jqgridwiki/doku.php?id=wiki:first_grid … I get the table but i cant get any information from the database
i have changed url:'example.php', to url:'controller.php',
In controller.php I have changed
$result = mysql_query("SELECT COUNT(*) AS count FROM invheader"); to the name of my table
I have changed all instances of invheader to my table name and the fields accordingly
I have changed the fields in the main html file as well.
In dbconfig I have defined the username, password and database name using the same variables as required by controller.php.
I dont understand now what I am doing wrong. Can anyone please help me with this???? Thanks for your time.
15:51

18/04/2010

ok i tried opening controller.php and it says that there is an sql syntax error in line 1 . This is my controller.php file. I really couldnt figure out an error here.
<?php
//include the information needed for the connection to MySQL data base server.
// we store here username, database and password
include("dbconfig.php");
// to the url parameter are added 4 parameters as described in colModel
// we should get these parameters to construct the needed query
// Since we specify in the options of the grid that we will use a GET method
// we should use the appropriate command to obtain the parameters.
// In our case this is $_GET. If we specify that we want to use post
// we should use $_POST. Maybe the better way is to use $_REQUEST, which
// contain both the GET and POST variables. For more information refer to php documentation.
// Get the requested page. By default grid sets this to 1.
$page = $_GET['page'];
// get how many rows we want to have into the grid - rowNum parameter in the grid
$limit = $_GET['rows'];
// get index row - i.e. user click to sort. At first time sortname parameter -
// after that the index from colModel
$sidx = $_GET['sidx'];
// sorting order - at first time sortorder
$sord = $_GET['sord'];
// if we not pass at first time index use the first column for the index or what you want
if(!$sidx) $sidx =1;
// connect to the MySQL database server
$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());
// select the database
mysql_select_db($database) or die("Error connecting to db.");
// calculate the number of rows for the query. We need this for paging the result
$result = mysql_query("SELECT COUNT(*) AS count FROM jos_chronoforms_ictjobrequest");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculate the total pages for the query
if( $count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
// if for some reasons the requested page is greater than the total
// set the requested page to total page
if ($page > $total_pages) $page=$total_pages;
// calculate the starting position of the rows
$start = $limit*$page - $limit;
// if for some reasons start position is negative set it to 0
// typical case is that the user type 0 for the requested page
if($start <0) $start = 0;
// the actual query for the grid data
$SQL = "SELECT recordtime, ipaddress, ext_number, problem_description, problem_type, department, username FROM jos_chronoforms_ictjobrequest ORDER BY $sidx $sord LIMIT $start , $limit";
$result = mysql_query( $SQL ) or die("Couldn't execute query.".mysql_error());
// we should set the appropriate header information. Do not forget this.
header("Content-type: text/xml;charset=utf-8");
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .= "<rows>";
$s .= "<page>".$page."</page>";
$s .= "<total>".$total_pages."</total>";
$s .= "<records>".$count."</records>";
// be sure to put text data in CDATA
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$s .= "<row id='". $row[cf_id]."'>";
$s .= "<cell>". $row[record_time]."</cell>";
$s .= "<cell>". $row[ipaddress]."</cell>";
$s .= "<cell>". $row[ext_numebr]."</cell>";
$s .= "<cell><![CDATA[". $row[problem_description]."]]></cell>";
$s .= "<cell>". $row[problem_type]."</cell>";
$s .= "<cell>". $row[department]."</cell>";
$s .= "<cell>". $row[username]."</cell>";
$s .= "</row>";
}
$s .= "</rows>";
echo $s;
?>
13:32

Moderators
30/10/2007

Hello,
Sorry this is not jqGrid related, but PHP related issue.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
63 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