出席シートをjqGridで作成したい。私はPHPとMySQLを使用しています出席シートをjqGridで作成する
私はMemberInfoと呼ばれ、1つは出席と呼ばれる2つのテーブルがあります。
From MemberInfoメンバーの姓と名字をグリッドに表示します。それから私は週の毎日のための箱を持っていたい。これらのフィールドにデータを追加すると、Attendanceテーブルにデータを保存することができます。また、Attendanceグリッドを再度生成すると、データを表示するために既に埋め込まれているフィールドが生成されます。
私の質問は どのように追加することができますか?これらの列を出席テーブルにどのように関連付けることができますか?ありがとう!
編集:私は、新しい列を生成し、cellEditでデータベースにデータを追加することができました
。 2つのテーブルのデータでグリッドを生成することには依然として問題があります。ありがとう!
これは明らかです。それが私に知らせてくれないならば!ありがとう!
<?php
require_once 'jqgrid/jq-config.php';
// include the jqGrid Class
require_once "jqgrid/php/jqGrid.php";
// include the driver class
require_once "jqgrid/php/jqGridPdo.php";
// Connection to the server
$conn = new PDO("mysql:host=localhost;dbname=db;","root",NULL);
// 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
$grid->SelectCommand = 'SELECT member_id, first_name, last_name FROM members_info WHERE member_type !=5';
// set the ouput format to json
$grid->dataType = 'json';
$grid->table ="members_info";
$grid->setPrimaryKeyId("member_id");
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('grid.php');
$grid->cacheCount = true;
// Set grid caption using the option caption
$today = date('Y-m-d');
if(isset($_POST['past_month'])){
$today = date('Y-m-d', strtotime($_POST['past_month']));
}
if(isset($_POST['next_month'])){
$today = date('Y-m-d', strtotime($_POST['next_month']));
}
$days = attendance_cal(date('F', strtotime($today)), date('Y', strtotime($today))); // Gets the days for that month and that year
sort($days); //sort the days
foreach($days as $day){
$grid->addCol(array(
"name"=>date('m-d', $day)
));
}
$grid->setGridOptions(array(
"caption"=>"This is custom Caption",
"rowNum"=>30000,
"sortname"=>"member_id",
"hoverrows"=>true,
"width"=>1000,
"height"=>1000,
"cellEdit"=> true,
"cellsubmit"=>"remote",
"cellurl"=> "cell_dump.php",
"rowList"=>array(10,20,50),
"postData"=>array("grid_recs"=>776)
));
// Change some property of the field(s)
$grid->setColProperty("member_id", array("label"=>"ID", "width"=>60, "editable"=>false));
$grid->setColProperty("first_name", array("label"=>"First Name", "width"=>120, "editable"=>false));
$grid->setColProperty("last_name", array("label"=>"Last Name", "width"=>120, "editable"=>false));
// Enjoy
$grid->navigator = false;
// and finaly bind key navigation
// This is way if no events or parameter
//$grid->callGridMethod('#grid', 'bindKeys');
//
//in case of passing events is better this way
$bindkeys =<<<KEYS
$("#grid").jqGrid('bindKeys', {"onEnter":function(rowid) { alert("You enter a row with id:"+rowid)} });
KEYS;
$grid->setJSCode($bindkeys);
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
?>
は私はより具体的にしてみましょう:: EDIT(これは簡単に私に知らせてくださいになるだろうPHPのための別のライブラリがある場合)
マイテーブル「のメンバーは、」フィールドを持っています"MEMBER_ID"、 "FIRST_NAME"、 "姓"
"出勤" テーブルのフィールドを有する "attendance_id"、 "MEMBER_ID"、 "attendance_date"、 "attendance_value"
グリッド、私はそれが次のようになりたい:
|メンバーID |名前| 03-15-2012 | 03-20-2012 | 03-22-2012 |
「Member Id」列と「Name」列は、「メンバー」表からSelectCommandを使用して生成されており、他の列はaddColを使用して作成されています。私はちょっとcellEditを使ってデータベースにデータを追加する方法を見つけ出すことができますが、シートを読み込むと、グリッド内のデータベースからのデータをメンバーテーブルから来るデータ以外に置く方法がわかりません。私はこれがより明確であることを望む!ありがとう!
申し訳ありませんが、あなたはより多くの技術的な要件のようではなく、質問等のサウンドを書いたものすべて。あなたの質問は何ですか? ([FAQ](http://stackoverflow.com/faq)を参照してください) – Oleg
もっと列を追加するにはどうすればいいですか?これらの列を出席テーブルにどのように関連付けることができますか?ありがとう! – raygo
downvote:まず宿題をしてください。私たちはあなたが最初に基礎を学んだら、あなたを助けるためにここにいる –