2 个页面,一个呈现,一个不呈现,都在同一个目录中

2 pages, one renders and one does not, both in same directory

我的报告网站上有 2 个页面的行为不一样。我正在使用 DataTables 服务器端处理。第一页只有 74 行 returned(我知道它并不真的需要使用服务器端处理),而另一页有 30,000 多行和 65 多列。第一个页面呈现得很好,第二个页面说找不到页面。

编辑

页面加载方式:

  1. 致电ReportPage.php
  2. included 文件 ContentSearchpage.php 计算将 returned 的列数和行数。 (不完全确定我是否仍然需要这部分,但还没有删除它)
  3. included 文件 DBConn.php 具有连接到我的 SQL DB
  4. 的所有连接信息
  5. 仅使用 theadtfoot 创建 table,所有 <th></th> 根据列表中的 return 列填写保存在我的 SQL DB
  6. DataTables 初始化如下所示,通过使用文件 ServerSide.PHP
  7. 将数据发送到服务器进行处理
  8. ServerSide.php 将收集到的信息发送到 FilterSort.class.php 服务器上用于处理的信息数据和 return 一个 JSON 字符串
  9. DataTables jquery 将 returned JSON 字符串格式化为 table

这是我初始化页面的方式:

<script type="text/javascript" class="init">
    $(document).ready(function ()
    {
        console.log("Test");
        $('#DataTable').DataTable({
            initComplete: function () {
                this.api().columns().every(function () {
                    var column = this;
                    var select = $('<select><option value=""></option></select>')
                            .appendTo($(column.footer()).empty())
                            .on('change', function () {
                                var val = $.fn.dataTable.util.escapeRegex($(this).val());
                                column.search(val ? '^' + val + '$' : '', true, false).draw();
                            });
                    column.data().unique().sort().each(function (d, j) {
                        select.append('<option value="' + d + '">' + d + '</option>')
                    });
                });
            },
            "lengthMenu": [[25, 50, 75, 100, 150], [25, 50, 75, 100, 150]],
            "ScrollX": true,
            "dom": '<"top"Biflp<"clear">>rt<"bottom"ip<"clear">>',
            "buttons": [
                {extend: 'collection', text: 'Selection', buttons: ['selectAll', 'selectNone']},
                {extend: 'collection', text: 'Export', buttons: ['excel', 'csv', 'pdf']}],
            "fixedHeader": {header: true, footer: false},
            "select": true,
            "processing": true,
            "serverSide": true,
            "ajax": {"url": "ServerSide.php?PageName=<?php echo $Page; ?>"}
        });
    });
</script>

这就是我开始页面的方式:

<h1>
    <?php
    echo $HeadingDesc;
    if (strpos($_SERVER['PHP_SELF'],"/",1) > 0)
    {
        echo "<br>Dev Site";
    }
    ?>
</h1>
<?php
//echo "<br>PageName: " . $Page;
//include('ContentPage.php');
//var_dump($Page);
//include ('Selected.php');
//var_dump($Page);
/* if(($Page == 'COEI_OPR' || $Page == 'OSP_OPR' || $Page == 'MaterialTracking' || $Page == 'MaterialReceived' || $Page == 'ApprovedProjects_PrevDay' || $Page == 'ApprovedProjects' || $Page == 'M6Action' || $Page == 'OPR_COEI' || $Page == 'OPR_OSP'))// && !isset($_GET['Project']))
  {
  require_once 'SearchTerm.php';
  //include 'ContentSearchPage.php';
  include 'DBConn.php';
  }
  else
  { */
include 'ContentSearchPage.php';
include 'DBConn.php';

$getHeadings   = $conn->query($hsql);
$rHeadings     = $getHeadings->fetchALL(PDO::FETCH_ASSOC);
$CountHeadings = count($rHeadings);
//print_r($hsql);
$tsqlHeadings  = '';
for ($row = 0; $row < $CountHeadings; $row++)
{
    $headings[$row] = $rHeadings[$row]["Headings"];
    $tsqlHeadings   = $tsqlHeadings."[".$headings[$row].'],';
}

if ($DataTable == 1)
{
    $CountTSQL = "Select count(*) ".$tsql;
    $tsql      = "Select ".substr($tsqlHeadings,0,strlen($tsqlHeadings) - 1).$tsql;
}
else
{
    $CountTSQL = "Select count(*) ".$tsql;
    $tsql      = "Select ".substr($tsqlHeadings,0,strlen($tsqlHeadings) - 1).$tsql." order by Id OFFSET $offset ROWS FETCH NEXT $limit ROWS ONLY";
}
?>
<table id="DataTable" class="display nowrap" style="width: 100%; border: 1px">
    <thead>
        <tr>
            <?php
            foreach ($headings as $heading)
            {
                ?>
                <th class="cell"><?php echo $heading; ?></th>
                <?php
            }
            ?>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <?php
            foreach ($headings as $heading)
            {
                ?>
                <th class="cell">
                    <?php echo $heading; ?>
                </th>
                <?php
            }
            ?>
        </tr>
    </tfoot>
</table>
<?php //}    ?>
</body>

ContentSearchPage.php:

<?php
case 'MaterialTrackingAll':
try
{
    include 'SearchParameters.php';
    include 'DBConn.php';

    $OneButton = 1;
    $Edit      = 0;
    $SQLArray  = array ("searchState" => $searchState,"searchProject" => $searchProject);

    $CountSQL    = "select count(*) from pmdb.v_MaterialTracking_OPCEN";
    $TotalRows   = $conn->query($CountSQL)->fetchColumn();
    $offset      = '';
    $currentpage = '';
    $DataTable   = 1;

    $tsql = " FROM pmdb.v_MaterialTracking_OPCEN";
    $hsql = "select Headings from TableHeadings where TableName = 'v_MaterialTracking_OPCEN' order by ID";
}
catch (Exception $e)
{
    die(print_r($e->getMessage()));
}
break;
case 'QDefs':
try
{
    include 'SearchParameters.php';
    include 'DBConn.php';
    $Edit      = 1;
    $OneButton = 1;
    $SQLArray  = array ("searchState" => $searchState,"searchProject" => $searchProject);

    $CountSQL  = "select count(*) from pmdb.v_QDefs";
    $TotalRows = $conn->query($CountSQL)->fetchColumn();
    if ($TotalRows > 500)
    {
        include 'NavButtons.php';
        $DataTable = 0;
    }
    elseif ($TotalRows <= 500)
    {
        $offset      = '';
        $currentpage = '';
        $DataTable   = 1;
    }
    $tsql = " from pmdb.v_QDefs";
    $hsql = "select Headings from TableHeadings where TableName = 'v_QDefs' and Headings != 'Edit' order by Id";
}
catch (Exception $e)
{
    die(print_r($e->getMessage()));
}
break;
?>

而文件 ServerSide.php 只是调用 ssp.class.php 的文件的修改版本here, and I modified the ssp.class.php 以便它使用 PDO::SQLSRV 而不是 MySql.

我可以 运行 第一页就好了,table 出现并且可以使用。第二个 table 没有出现。我只收到 header,然后是一条消息:

404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

不知道是什么问题

我已经弄明白了。

我正在通过 $_GET 发送所有内容。我发送的内容的长度超过了限制,所以它会失败。我改变了它的发送方式,现在使用 $_POST 所以发送数据。表格现在按应有的方式呈现。

"ajax" : {
      "url" : "./ServerSide.php",
      "type": "POST"
     }