嗨,我是使用的新成员。我创建了3个文件,project.php、projectdetail.php和get_project_detail.php
这是我的project.php代码
...
...
<table id="dg" title="Next Target" class="easyui-datagrid" style="width:700px;height:automatic"
url="get_project_nt.php"
pagination="true"
rownumbers="true"
fitColumns="true"
singleSelect="true">
<thead>
<tr>
<th formatter="formatProjectId" width="165" sortable="true" field="projectname">Project Name</th>
<th width="100" sortable="true" field="target">Target End Of 2014</th>
<th width="100" sortable="true" field="PIC">PIC</th>
<th width="75" sortable="true" field="begindate">Begin</th>
<th width="75" sortable="true" field="enddate">End</th>
<th formatter="formatProgress" width="150" sortable="true" field="progress">Progress</th>
</tr>
</thead>
</table>
...
...
<script type="text/javascript">
function formatProjectId(val,row){
var url = "projectdetail.php?id=";
return '<a href="'+url + row.projectname+'">'+val+'</a>';
}
</script>我使用格式化程序="formatProjectId"将id值抛出为projectdetail.php文件
这是文件projectdetail.php
...
...
<?
include 'conn.php';
$query = "SELECT * FROM project WHERE projectname ='".$_GET['id']."'";
$hasil = mysql_query($query);
while ($data = mysql_fetch_array($hasil))
{
echo"<table>";
echo "<tr><td>Nama project</td> <td>:</td><td>$data[projectname]</td></tr>";
echo "<tr><td>Target End of</td> <td>:</td><td>$data[target]</td></tr>";
echo "<tr><td>Last Update</td> <td>:</td><td>$data[lastupdate]</td></tr>";
echo"</table>";
?>
</table>
<table id="dg" title="All Project" class="easyui-datagrid" style="width:automatic;height:automatic"
url="get_project_detail.php"
toolbar="#toolbar"
pagination="true"
rownumbers="true"
fitColumns="true"
singleSelect="true">
<thead>
<tr>
<th width="165" sortable="true" field="projectactivity">Project Activity</th>
<th width="100" sortable="true" field="target">Target</th>
<th width="100" sortable="true" field="actual">Actual</th>
<th width="75" sortable="true" field="problemident">Problem Identification</th>
<th width="75" sortable="true" field="correctiveact">Corrective Action</th>
<th width="75" sortable="true" field="duedate">Due Date</th>
<th width="75" sortable="true" field="PIC">PIC</th>
</tr>
</thead>
</table>
...
...这是文件get_project_detail.php
<?php
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$sort = isset($_POST['sort']) ? strval($_POST['sort']) : 'projectactivity';
$order = isset($_POST['order']) ? strval($_POST['order']) : 'asc';
$projectname = isset($_POST['projectname']) ? mysql_real_escape_string($_POST['projectname']) : '';
$offset = ($page-1)*$rows;
$result = array();
include 'conn.php';
$where = "projectactivity like '%$projectname%'";
$rs = mysql_query("select count(*) from dproject");
$row = mysql_fetch_row($rs);
$result["total"] = $row[0];
$rs = mysql_query("select * from dproject where " . $where . " order by $sort $order limit $offset,$rows");
$items = array();
while($row = mysql_fetch_object($rs)){
array_push($items, $row);
}
$result["rows"] = $items;
echo json_encode($result);
?>这是数据库表:
项目
idproject
类别
项目名称
目标
图图
电子邮件
初学
终期
进展
dproject
iddproject
idproject
项目活动
目标
实际
有问题
纠正行为
杜伊达
图图
我们可以在文件projectdetail.php中看到两个表
第一个表从数据库上的表项目获取数据,第二个表从数据库上的表dproject获取数据。
第一个表是成功地根据从文件project.php.发送的id获取数据。
但是,在第二个表中,我想从表project.idproject=dproject.idproject中获取数据,它基于项目和dproject之间的相同id,可能与这个类似,但它不起作用。大家能给我解释一下我的错误代码在哪里吗?
发布于 2014-08-29 21:38:07
我看到你想要显示为子网格,对吗?Easyui有这个特性,您可以轻松使用,请看教程,并查看演示。
http://www.jeasyui.com/tutorial/datagrid/datagrid22.php
您可以将此作为理解结构文件的参考:
查看示例代码onExpandrow,您应该链接到project_detail_json.php --不要忘记在这里下载js文件
https://stackoverflow.com/questions/23508658
复制相似问题