Forum

July 12th, 2025
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
jqgrid example problems
30/09/2009
23:35
Avatar
thesheff17
New Member
Members
Forum Posts: 1
Member Since:
01/10/2009
sp_UserOfflineSmall Offline

I need some help getting the example working.  I'm pretty much have exactly what is on the examples page:

I get a grid with no data:

http://99.69.43.34/test/test.html

I know Mysql Apache PHP are working together here:

http://99.69.43.34/index.php

How do you know if the javascript is actually calling the php file correctly? 

Any help would be greatly appreciated.

****update***

I had some things wrong in the PHP file.  It looks like everything is working because I print out the SQL statement and it runs fine in the query browser.  As soon as I commet out the echo statement for the SQL and run the PHP script again it prompts me to download the PHP file.  I don't understand why this is happening?

can someone post their entire PHP file for example.  I think it has to do with the header stuff but not 100%.

***old stuff ****

I have created a database called email and basically have the exact data that the example has:

mysql> describe items;
+——-+————-+——+—–+———+—————-+
| Field | Type        | Null | Key | Default | Extra          |
+——-+————-+——+—–+———+—————-+
| index | int(11)     | NO   | PRI | NULL    | auto_increment |
| name  | varchar(50) | NO   |     | NULL    |                |
| code  | int(11)     | NO   |     | NULL    |                |
+——-+————-+——+—–+———+—————-+
3 rows in set (0.00 sec)

mysql> select * from items;
+——-+———–+——+
| index | name      | code |
+——-+———–+——+
|    18 | dsheffner |    1 |
|    19 | dsheffner |    2 |
|    20 | dsheffner |    3 |
|    21 | dsheffner |    4 |
|    22 | dsheffner |    5 |
+——-+———–+——+
5 rows in set (0.00 sec)

Here is my PHP:

<?php
ini_set('max_execution_time', 600);
#include(”dbconfig.php”);
// coment the above lines if php 5
include(”JSON.php”);
$json = new Services_JSON();
// end comment
$examp = $_GET["q"]; //query number

$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;

if(isset($_GET["nm_mask"]))
        $nm_mask = $_GET['nm_mask'];
else
        $nm_mask = “”;
if(isset($_GET["cd_mask"]))
        $cd_mask = $_GET['cd_mask'];
else
        $cd_mask = “”;
//construct where clause
$where = “WHERE 1=1″;
if($nm_mask!='')
        $where.= ” AND item LIKE '$nm_mask%'”;
if($cd_mask!='')
        $where.= ” AND item_cd LIKE '$cd_mask%'”;

// connect to the database
$dbhost = 'localhost';
$dbuser = 'root';
$dbpassword = 'pass';
$database = 'email';
$db = mysql_pconnect($dbhost, $dbuser, $dbpassword)
or die(”Connection Error: ” . mysql_error());

mysql_select_db($database) or die(”Error conecting to db.”);

$result = mysql_query(”SELECT COUNT(*) AS count FROM items “.$where);
$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;
if ($limit<0) $limit = 0;
$start = $limit*$page – $limit; // do not put $limit*($page – 1)
if ($start<0) $start = 0;
$SQL = “SELECT item_id, item, item_cd FROM items “.$where.” ORDER BY $sidx $sord LIMIT $start , $limit”;
$result = mysql_query( $SQL ) or die(”Couldn't execute query.”.mysql_error());
$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[item_id];
    $responce->rows[$i]['cell']=array($row[item_id],$row[item],$row[item_cd]);
    $i++;
}
echo $json->encode($responce); // coment if php 5
//echo json_encode($responce);
mysql_close($db);
?>

03/10/2009
03:32
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

In the example I got error  - JQuery is not defined. See installatin instructions.

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
43 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