Created
June 19, 2019 11:13
-
-
Save rob2009/01ade64ceac311f7b4e6abd256b0ebfb to your computer and use it in GitHub Desktop.
PHPgrid.org problem using value from POST input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* PHP Grid Component | |
* @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org | |
* @version 2.0.0 | |
* @license: see license.txt included in package | |
*/ | |
include_once("../../config.php"); | |
include(PHPGRID_LIBPATH."inc/jqgrid_dist.php"); | |
$db_conf = array("type"=> PHPGRID_DBTYPE, "server"=> PHPGRID_DBHOST,"user"=> PHPGRID_DBUSER,"password"=> PHPGRID_DBPASS,"database" => PHPGRID_DBNAME); | |
if (!empty($_POST["name"])) | |
{$_SESSION["name"] = $_POST["name"]; | |
$SelectedName = $_SESSION["name"]; | |
} | |
$SelectedName="Ana"; | |
$searchstring = "SELECT client_id,name FROM clients WHERE name LIKE '%{$SelectedName}%'"; | |
$g = new jqgrid($db_conf); | |
$g->select_command =$searchstring; | |
$g->table = "clients"; | |
$col = array(); | |
$col["title"] = "Id"; // caption of column | |
$col["name"] = "client_id"; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Client"; | |
$col["name"] = "name"; | |
$cols[] = $col; | |
$g->set_columns($cols); | |
$out = $g->render("list1"); | |
?> | |
<!DOCTYPE html><head> <meta charset="utf-8"> | |
<link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/redmond/jquery-ui.custom.css"></link> | |
<link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link> | |
<script src="../../lib/js/jquery.min.js" type="text/javascript"></script> | |
<script src="../../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script> | |
<script src="../../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script> | |
<script src="../../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script> | |
</head><body> | |
<?php | |
echo $out; | |
echo $searchstring; | |
?> | |
<form action="" method="post" name="myForm"> | |
Name:<input id="name" type="name" name="name"> | |
<input type="submit" value="Submit"> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This uses the demo database that comes with phpgrid.org and uses the $_POST handling suggested in FAQ>Misc
As it stands the search returns just the 2 entries that match.
If you comment this out: line 16 $SelectedName="Ana"; and repeat the search with form input name=Ana, in that case the search returns all items in the database.