AxelKishore
AxelKishore

Reputation: 17

error in pagination

Only the first page works

When i click the links to pages

I get this error

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster. Error 404 localhost Apache/2.4.2 (Win32) OpenSSL/1.0.1c PHP/5.4.4

This is my code

<?php
        //connect to our DB
        mysql_connect( 'localhost', 'root', 'password') ;
        mysql_select_db( 'test1' ) ;

        //preparing our variable.
        if( !isset( $_GET['p'] ) ) {$_GET['p']=0;}
        $per_page= 6 ;
        $sql=  " SELECT name FROM pagination " ;
        $sql2= " SELECT name FROM pagination  ORDER BY id DESC LIMIT ".$_GET['p']."," . $per_page; 
        $query= mysql_query ( $sql2 ) ;
        $rows=  mysql_num_rows ( mysql_query ( $sql ) ) ;
        $page=  ceil ( $rows / $per_page ) ;

        while( $fetch= mysql_fetch_assoc( $query ) ) {
            echo '<p>' . $fetch['name'] . '</p>' ;
        }

        for( $i=0;$i<$page;$i++ ){

            echo' <a href="index.php?p='. ( $i * $per_page ) . '">'. ( $i + 1 ) .'</a> ' ;

        }

    ?>

Upvotes: 0

Views: 1439

Answers (1)

LSerni
LSerni

Reputation: 57388

This is an Apache error, meaning that you made some mistake in the HREF.

As far as I can see the href will yield "index.php?p=somevalue" which is a valid URL.

The only possibility I see is that you... don't have an index.php file? (e.g. your actual script isn't called index.php all lowercase, but something else)

Upvotes: 3

Related Questions