无法摆脱这种错误

时间:2015-02-11 04:23:14

标签: php html

所以我一直在研究一些需要在页面中显示数据库表的项目,但由于它有很多数据我使用分页使它看起来更简单,代码运行得很完美而且桌子以正确的方式显示。

但是我收到了以下错误消息:

  

注意:未定义的变量:_PHP_SELF in   第74行的C:\ xampp \ htdocs \ test2 \ test4.php

那个烦我的原因是因为我无法找到它是什么以及如何从我的页面中删除它,我需要帮助因为这个项目截止日期即将结束

所以这里是代码

<html>
<head>
<title>Paging Using PHP</title>
</head>
<body>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$rec_limit = 10;

$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}
mysql_select_db('test1');
/* Get total number of records */
$sql = "SELECT count(msisdn) FROM bbs_1 ";
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not get data: ' . mysql_error());
}
$row = mysql_fetch_array($retval, 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 bill_cycle, total_bill_amount, total_outstanding_amount ".
       "FROM bbs_1 ".
       "LIMIT $offset, $rec_limit";

$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not get data: ' . mysql_error());
}
    echo"<table>".
            "<tr>".
                "<td>CYCLE</td>".
                "<td>TOTBILL</td>".
                "<td>OUTSTANDING</td>".
            "</tr>";
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
    echo 
            "<tr>".
                "<td>{$row['bill_cycle']} </td>".
                "<td>{$row['total_bill_amount']}</td>".
                "<td>{$row['total_outstanding_amount']}</td>".
             "</tr>";

} 
echo "</table>";
if( $page > 0 )
{
   $last = $page - 2;
   echo "<a href=\"$_PHP_SELF?page=$last\">Last 10 Records</a> |";
   echo "<a href=\"$_PHP_SELF?page=$page\">Next 10 Records</a>";
}
else if( $page == 0 )
{
   echo "<a href=\"$_PHP_SELF?page=$page\">Next 10 Records</a>";
}
else if( $left_rec < $rec_limit )
{
   $last = $page - 2;
   echo "<a href=\"$_PHP_SELF?page=$last\">Last 10 Records</a>";
}
mysql_close($conn);
?>

希望你能找到问题,

1 个答案:

答案 0 :(得分:0)

浏览器会在只给出问号和查询字符串的情况下找出要做的事情;没有必要告诉它将它们应用到当前URL。