0
我的報告網站上有2個頁面的行爲不相同。我正在使用DataTables服務器端處理。第一頁只有74行返回(我知道它並不需要使用服務器端處理),而另一頁有超過30,000行,列數超過65。第一頁呈現得很好,第二頁說它找不到頁面。2頁,一個呈現,一個不在同一目錄中
編輯
如何頁面加載:
- 電話ReportPage.php
included
文件ContentSearchpage.php數多少列將返回多少行。 (不能完全肯定,我仍然需要這部分,但沒有帶移除它尚未)included
文件DBConn.php擁有所有的連接信息用於連接到我的SQL數據庫- 創建表只是
thead
和tfoot
,所有的<th></th>
填寫基於列從我保持我的SQL數據庫 - 數據表進行初始化列表中返回由數據發送到服務器使用文件ServerSide.PHP 處理如下圖所示
- ServerSide.php將收集到的信息,以FilterSort.class.php這正是用來在服務器上處理數據,並返回一個JSON字符串
- jQuery的數據表格式返回的JSON字符串表
這如何我初始化頁面:
<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僅僅是一個修改,從here調用ssp.class.php文件的版本,我修改了ssp.class.php,以便它使用PDO :: SQLSRV而不是MySql。
我可以運行第一頁就好了,表出來,可行。第二張桌子沒有出現。我只收到標題,然後顯示一條消息:
404 - 找不到文件或目錄。 您正在查找的資源可能已被刪除,名稱已更改或暫時不可用。
我不知道是什麼問題。
我的猜測是你已經複製了第二個文件,所以它的權限不允許讀取或執行www用戶。這可能是,如果你已經使用本身沒有足夠權限的文件讀取器複製文件。 – davidkonrad
@davidkonrad如果是這樣的話,那麼我就不會有任何一頁的表格。他們都使用同一組文件。我更新了我的問題,希望能夠澄清這一點。在不同頁面之間唯一改變的是被髮送到* ServerSide.php *文件的'PageName',它被用作返回數據的SQL表名。 – Mike