-4

i have search page where i limit results and split pages....... hi i am using "$page = $_GET['page'];" command but if there is no ?page=1 then it is displaying ""Error Undefined index: page"" if i put ?page=1 then there is no error. my problem is this that at the very first time when i run my page print_marks.php then i can not put ?page=1 but when i press next button within the page ?page=2 automatically appeares in the url.

here is my code

$query = "SELECT COUNT(mdl_assignment_submissions.userid) As num FROM mdl_assignment_submissions Where mdl_assignment_submissions.assignment = 1";
    $total_pages = mysql_fetch_array(mysql_query($query));
    $total_pages = $total_pages['num'];


    $targetpage = "Print_Marks.php";    
    $limit = 25;    
    $page = "1";
    $page = $_GET['page'];

    if($page) 
        $start = ($page - 1) * $limit;          
    else
        $start = 0; 
4

2 回答 2

2

Try to use instead

$page = $_GET['page'];

this

$page = isset($_GET['page']) ? $_GET['page'] : 1;
于 2013-11-06T14:47:20.163 回答
1

You could use $page = (isset($_GET['page']) ? $_GET['page'] : 1;

You're getting the error because sometimes page is not set.

于 2013-11-06T14:47:02.693 回答