我知道它是爲了排序,但現在頁面無法正常工作。現在沒有什麼打印到我的error_logs中。PHP通過從數據庫的分頁表中排序
用戶紅酸幫助我們解決了遺漏的空白問題,並使用字符串變量而不是PHP_SELF。
一旦我按下下一個記錄,我得到:
未找到
請求的URL /surf/$index.php此服務器上找到。
此外,在嘗試 使用ErrorDocument來處理請求時遇到404未找到錯誤。
我的代碼:
<?php
$dbHost = "localhost";
$dbUser = "";
$dbPass = "";
$dbName = "";
$tbl_name="";
$rec_limit = 20;
$order = "ORDER BY";
$scriptname = 'index.php';
mysql_connect("$dbHost", "$dbUser", "$dbPass")or die("cannot connect");
mysql_select_db("$dbName")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name $order ".$_GET["orderby"]." ".$_GET["desc"];
$result=mysql_query($sql);
$sql = "SELECT count(steamid) FROM $tbl_name";
$result= mysql_query($sql);
if(! $result)
{
die('Could not get data: ' . mysql_error());
}
$row = mysql_fetch_array($result, MYSQL_NUM);
$rec_count = $row[0];
if(isset($_GET{'page'}))
{
$page = $_GET{'page'} + 1;
$offset = $rec_limit * $page ;
}
else
{
$page = 0;
$offset = 0;
}
$left_rec = $rec_count - ($page * $rec_limit);
$sql = "SELECT * ".
"FROM $tbl_name ".
"$order points DESC ".
"LIMIT $offset, $rec_limit";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><?php echo $rows['name']; ?></td>
<td><?php echo $rows['points']; ?></td>
<td><?php echo $rows['winratio']; ?></td>
<td><?php echo $rows['pointsratio']; ?></td>
<td><?php echo $rows['finishedmaps']; ?></td>
<td><?php echo $rows['lastseen']; ?></td>
</tr>
</tr>
<?php
}
if($page > 0)
{
$last = $page - 2;
echo "<a href=\"$scriptname?page=$last\">Last 10 Records</a> |";
echo "<a href=\"$scriptname?page=$page\">Next 10 Records</a>";
}
else if($page == 0)
{
echo "<a href=\"$$scriptname?page=$page\">Next 10 Records</a>";
}
else if($left_rec < $rec_limit)
{
$last = $page - 2;
echo "<a href=\"$$scriptname?page=$last\">Last 10 Records</a>";
}
mysql_close();
?><?php
$dbHost = "localhost";
$dbUser = "c1226125_ms";
$dbPass = "wR(@ucrb5oG.";
$dbName = "c1226125_timer";
$tbl_name="ck_playerrank";
$rec_limit = 20;
$order = "ORDER BY";
$scriptname = 'index.php';
mysql_connect("$dbHost", "$dbUser", "$dbPass")or die("cannot connect");
mysql_select_db("$dbName")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name $order ".$_GET["orderby"]." ".$_GET["desc"];
$result=mysql_query($sql);
$sql = "SELECT count(steamid) FROM $tbl_name";
$result= mysql_query($sql);
if(! $result)
{
die('Could not get data: ' . mysql_error());
}
$row = mysql_fetch_array($result, MYSQL_NUM);
$rec_count = $row[0];
if(isset($_GET{'page'}))
{
$page = $_GET{'page'} + 1;
$offset = $rec_limit * $page ;
}
else
{
$page = 0;
$offset = 0;
}
$left_rec = $rec_count - ($page * $rec_limit);
$sql = "SELECT * ".
"FROM $tbl_name ".
"$order points DESC ".
"LIMIT $offset, $rec_limit";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><?php echo $rows['name']; ?></td>
<td><?php echo $rows['points']; ?></td>
<td><?php echo $rows['winratio']; ?></td>
<td><?php echo $rows['pointsratio']; ?></td>
<td><?php echo $rows['finishedmaps']; ?></td>
<td><?php echo $rows['lastseen']; ?></td>
</tr>
</tr>
<?php
}
if($page > 0)
{
$last = $page - 2;
echo "<a href=\"$scriptname?page=$last\">Last 10 Records</a> |";
echo "<a href=\"$scriptname?page=$page\">Next 10 Records</a>";
}
else if($page == 0)
{
echo "<a href=\"$$scriptname?page=$page\">Next 10 Records</a>";
}
else if($left_rec < $rec_limit)
{
$last = $page - 2;
echo "<a href=\"$$scriptname?page=$last\">Last 10 Records</a>";
}
mysql_close();
?>
你能分享哪些行產生這些錯誤嗎? – Mureinik
他們在引號中。 –
它是'$ _GET'嗎?或'$ _POST'? – aldrin27