Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从Jquery EasyUI中的2个mysql表中选择数据_Php_Jquery_Mysql_Jquery Easyui - Fatal编程技术网

Php 从Jquery EasyUI中的2个mysql表中选择数据

Php 从Jquery EasyUI中的2个mysql表中选择数据,php,jquery,mysql,jquery-easyui,Php,Jquery,Mysql,Jquery Easyui,嗨,我是使用jqueryeasyui的新手。 我创建了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"

嗨,我是使用jqueryeasyui的新手。 我创建了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>
...
...
<?
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>
...
...
<?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);
?>
。。。
...
项目名称
目标2014年底
照片
开始
终点
进展
...
...
函数formatProjectId(val,行){
var url=“projectdetail.php?id=”;
返回“”;
}
我使用formatter=“formatProjectId”将id值抛出到projectdetail.php文件中

这是文件projectdetail.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>
...
...
<?
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>
...
...
<?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);
?>
。。。
...

我看到您希望显示为子网格,对吗? Easyui有这个功能,你可以很容易地使用它,请看一下教程,看看演示

您可以将其用作了解结构文件的参考:

  • 表的主文件,例如:project_list.php(输出为html,body table generate grid)
  • 获取数据项目_data_json.php的文件(输出为json编码)
  • 获取项目详细信息列表的第二个db网格文件,例如:project_detail_json.php(输出为json编码)
  • 查看示例代码onExpandrow,您应该链接到project_detail_json.php
    别忘了你应该在这里下载js文件

    如果这是正确答案,请标记为答案。谢谢