English 中文(简体)
JqGrid不节省数据库数据
原标题:JqGrid not saving data to database

i 我正试图建立一个与格格格格格格格格格格格格格格格格格格格格格格格格格格格格格格格为一体的和谐的电网——然而,我无法从数据库中获取数据。 我是最新的html。 我似乎正在从一角开始的圈子里......

many thanks

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DT…..strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8″ />
<title>xxxxxx</title>
<link rel="stylesheet" type="text/css" href="timesheet_login.css">
<link rel="stylesheet" media="print" href="print.css" type="text/css">
<link rel="shortcut icon" href="oneline_logo.gif">
<link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />

<style type="text/css">
html, body {
    margin: 0;
    padding: 0;
    font-size: 75%;
}
</style>

<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="scripts/js/jqModal.js" type="text/javascript"></script>
<script src="scripts/js/jqDnR.js" type="text/javascript"></script>



<script type="text/javascript">
$(function(){ 
  $("#rota").jqGrid({
    url: example.php ,
    datatype: "json",
 mtype:  POST ,
    colNames:[ Date ,  HPJ ,  Recycler , CCTV , Assistant ],
    colModel:[
     {name: date ,index: date , width:90,editable:true},
     {name: hpj ,index: hpj , width:100,editable:true},
      {name: recycler ,index: recycler , width:100,editable:true},
      {name: cctv ,index: cctv , width:100,editable:true},
   {name: assistant ,index: assistant , width:100,editable:true}
    ],
 rowNum:10,
    rowList:[10,20,30],
    pager:  #pcelltbl ,
    sortname:  date ,
    viewrecords: true,
    sortorder: "desc",
    caption:"Cell Edit Example",
 forceFit : true,
 cellEdit: true,
 cellsubmit:  clientArray ,
 editurl: example.php?action=save 
});

jQuery("#rota").jqGrid( navGrid , #pgwidth ,{edit:false,add:false,del:false});
});
</script>


</head>
<body>

<div id="topcontent">
 <br><br>
</div><!– end topcontainer –>

<div id="centercontent">

<table id="rota"><tr><td/></tr></table> 
<div id="pager"></div>

<script src="celledit.js" type="text/javascript"> </script>

</div>

<div id="footercontent">
</div><!– end footercontent –>

</body>
</html>

example.php:

<?php 
$dbhost = xxxxx.com ;  $dbuser =  xxx ;  $dbpassword =  xxx ;  $dbdatabase = xxxx;

$page = $_REQUEST[ page ];  // get the requested page
$limit = $_REQUEST[ rows ]; // get how many rows we want to have into the grid
$sidx = $_REQUEST[ sidx ]; // get index row - i.e. user click to sort
$sord = $_REQUEST[ sord ]; // get the direction
if(!$sidx) $sidx =1;

// connect to the database
$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());
mysql_select_db($dbdatabase) or die("Error conecting to db.");
$result = mysql_query("SELECT COUNT(*) AS count FROM rota"); 
$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;
$start = $limit*$page - $limit; // do not put $limit*($page - 1)
if($start <0) $start = 0; 


$SQL = "SELECT date, hpj, recycler, cctv, assistant FROM rota 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[] = array( id =>$row[ date ], "cell"=>array($row[ date ], $row[ hpj ], $row[ recycler ], $row[ cctv ], $row[ assistant ]));



}        
echo json_encode($responce);

?>
最佳回答

http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3acell_editing#properties” rel=“nofollow” 。 您应使用<条码>缩略语:远距离和<条码> 优异>/代码>而不是<条码>:用户。 当然,你需要在服务器部分(参考cellurlURL)上写出该代码,该编码可节省数据库的改动。 选择<代码>editurl界定了用于在线和格式编辑但并非用于单位编辑的URL。

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签