hiiiii im a newbie in using jqgrid the bottons in the navgrid are non cliquable ??? and pleaase i need someone to check and correct my code or provide me with an example to edit and delete and thanks a lotÂ
final.htmlÂ
final.php
// Include the information needed for the connection to
// MySQL data base server.
include(“dbconfig.php”);
//since we want to use a JSON data we should include
//encoder and decoder for JSON notation
//If you use a php >= 5 this file is not needed
//include(“JSON.php”);
// create a JSON service
//$json = new Services_JSON();
// to the url parameter are added 4 parameter
// we shuld get these parameter to construct the needed query
// for the pager
// get the requested page
$page = $_GET;
// get how many rows we want to have into the grid
// rowNum parameter in the grid
$limit = $_GET;
// get index row – i.e. user click to sort
// at first time sortname parameter – after that the index from colModel
$sidx = $_GET;
// sorting order – at first time sortorder
$sord = $_GET;
// if we not pass at first time index use the first column for the index
if(!$sidx) $sidx =1;
// connect to the MySQL database server
$db = mysql_connect(“localhost”, “root”, “”)
or die(“Connection Error: ” . mysql_error());
// select the database
mysql_select_db(“gestion_conges”) or die(“Error conecting to db.”);
// calculate the number of rows for the query. We need this to paging the result
$result = mysql_query(“SELECT COUNT(*) AS count FROM utilisateur “);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row;
// calculation of total pages for the query
if( $count >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; // do not put $limit*($page – 1)
// 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 * FROM utilisateur ORDER BY $sidx $sord LIMIT $start , $limit”;
$result = mysql_query( $SQL ) or die(“Couldn t execute query.”.mysql_error());
// constructing a JSON
$responce= new stdClass ();
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0;
$tab=array();
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$element=array(‘id’=>$row,
‘cell’ =>array($row,$row,$row,$row,$row));
// $responce->rows[$i]=$row[0];
// $responce->rows[$i]=array($row[nom],$row[prenom],$row[date],$row[cin],$row[type],$row[num1],$row[num2],$row[adresse],$row[matricule]);
$i++;
$tab[]=$element;
}
$responce->rows=$tab;
// return the formated data
//echo $json->encode($responce);
echo json_encode($responce);
?>
finalEdit.php
mysql_connect(“localhost”,”root”,””);
mysql_select_db(“gestion_conges”);
if (($_POST) == “edit”) {
$updateSQL = sprintf(“UPDATE utilisateur SET nom=%s, prenom=%s, date=%s, role=%s WHERE cin=%s”,
GetSQLValueString($_POST, “text”),
GetSQLValueString($_POST, “text”),
GetSQLValueString($_POST, “date”),
GetSQLValueString($_POST, “text”),
GetSQLValueString($_POST, “text”));
$Result1 = mysql_query($updateSQL) or die(mysql_error());
}
else if (($_POST) == “del”) {
$deleteSQL = sprintf(“DELETE FROM utilisateur WHERE id=%s”,
GetSQLValueString($_POST, “text”));
mysql_select_db($database_intranet);
$Result1 = mysql_query($deleteSQL) or die(mysql_error());
}
?>
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top