November 2nd, 2014

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_Related Related Topics sp_TopicIcon
Dynamic SQL for jqgrid
Forum Posts: 5
Member Since:
sp_UserOfflineSmall Offline

I am using Apache/PHP/MySQL web server and I'm trying to load a grid. I followed the demo to get a working grid with my data, and I have an index.php page that simply includes the maininteractionsgrid.php (pasted below). Now I would like to be able to add a WHERE statement to the sql based on a variable that has already been assigned in the index.php. I can get the WHERE statement to work if I specify a fixed number (i.e. siteid=10), but for some reason it won't work if I specify the variable (i.e. siteid=$siteid... $siteid has already been set to 10). Can someone PLEASE help me figure out why my code below isn't working? I have tried searching all over online and can't find anything as to why my code isn't going through. All I would like to do is get only the records for a certain site based on a passed variable, $siteid. Any help would be greatly appreciated. Thanks.


require_once 'jqinteractionsconfig.php';

// include the jqGrid Class

require_once ABSPATH."php/jqGrid.php";

// include the driver class

require_once ABSPATH."php/jqGridPdo.php";

// Connection to the server


// Tell the db that we use utf-8

$conn->query("SET NAMES utf8");

// Create the jqGrid instance

$grid = new jqGridRender($conn);

// Write the SQL Query

$mysql = "SELECT InteractionID, InteractionDateTime, ContactID, ContactedBy, InteractionType, Notes, SiteID FROM tbl_interactions WHERE SiteID=$siteid";

$grid->SelectCommand = $mysql;

// Set the table to where you add the data

$grid->table = 'tbl_interactions';

// Set output format to json

$grid->dataType = 'json';

// Let the grid create the model


// Set the url from where we obtain the data











    ), "first");

$grid->setColProperty('InteractionID', array("editable"=>false));

// Set some grid options






// Enjoy

$grid->renderGrid('#grid','#pager',true, null, null, true,true);

$conn = null;


Forum Timezone: Europe/Sofia

Most Users Ever Online: 496

Currently Online:
28 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,

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information