【发布时间】:2014-05-07 04:19:31
【问题描述】:
您好,我是使用 jquery easyui 的新手。
我创建了 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>
我使用 formatter ="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
idd项目
idproject
项目活动
目标
实际
有问题
纠正措施
截止日期
图片
我们可以在文件projectdetail.php中看到2个表格
第一个表从数据库上的表 project 中获取数据,第二个表从数据库上的表 dproject 中获取数据。
第一个表是成功地根据从文件 project.php 发送的 id 获取数据。
但是在第二张表上,我想根据 project 和 dproject 之间的相同 ID 从表 dproject 中获取数据,可能就像这样 project .idproject=dproject.idproject 但它不起作用。大家能解释一下我的错误代码在哪里吗?
【问题讨论】:
标签: php jquery mysql jquery-easyui