Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1110963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:28:25+00:00 2026-05-17T02:28:25+00:00

i am writing code of pagination & i got an error. this is my

  • 0

i am writing code of pagination & i got an error.
this is my code :

<?php 
mysql_connect("localhost", "root", "") or die(mysql_error()); 
mysql_select_db("Admin") or die(mysql_error()); 

if (isset($_GET["page"]))
 {
 $page  = $_GET["page"]; 
 }
 else
 {
 $page=1;
 }



$start_from = ($page-1) * 2; 
$sql = "SELECT * FROM events ORDER BY event ASC LIMIT $start_from, 2"; 
$result = mysql_query ($sql) or die(mysql_error()); 
$num=mysql_numrows($result);
$x=0;
?> 
<table>
<tr><td>Event</td><td>Types</td></tr>
<?php 
while ($x<$num) {
$row1 = mysql_result($result,$x,'event');
$row2 = mysql_result($result,$x,'types'); 
?> 
            <tr>
            <td><? echo $row1; ?></td>
            <td><? echo $row2; ?></td>
            </tr>
<?php 
$x++;
} 
?> 
</table>
<?php 
$sql = "SELECT COUNT(event) FROM events"; 
$result = mysql_query($sql) or die(mysql_error()); 
$row = mysql_fetch_row($result); 
$total_records = $row[0]; 
$total_pages = ceil($total_records / 2); 

for ($i=1; $i<=$total_pages; $i++) { 
            echo "<a href='pagination.php?page=".$i."'>".$i."</a> "; 
}

?>

now i got an error.

  object not found
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:28:26+00:00Added an answer on May 17, 2026 at 2:28 am

    Note that instead of terrible while ($x<$num) you should use way more neat while($row=mysql_fetch_array($res))
    so, make it

    <?
    $per_page = 2;
    $page = 1;
    if (isset($_GET['page'])) $page = $_GET['page'];
    $start_from = ($page-1) * $per_page; 
    $sql = "SELECT * FROM events ORDER BY event ASC LIMIT $start_from, $per_page"; 
    $res = mysql_query ($sql) or trigger_error(mysql_error().": ".$sql);
    ?> 
    <table>
      <tr><td>Event</td><td>Types</td></tr>
    <?php 
    while($row=mysql_fetch_array($res)) {
    ?> 
      <tr>
        <td><? echo $row['event'] ?></td>
        <td><? echo $row['types'] ?></td>
      </tr>
    <?php 
    } 
    ?> 
    </table>
    <?php 
    $sql = "SELECT COUNT(event) FROM events"; 
    $res = mysql_query ($sql) or trigger_error(mysql_error().": ".$sql);
    $row = mysql_fetch_row($res); 
    $total_records = $row[0]; 
    $total_pages = ceil($total_records / $per_page); 
    
    for ($i=1; $i<=$total_pages; $i++) { 
      echo "<a href='pagination.php?page=".$i."'>".$i."</a> "; 
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While writing code in a file that would comprise of PHP, HTML, CSS &
I use this code for writing in the center : echo <div class='pagination' align
We are writing some code to control the pagination of results returned from a
I'm writing code in PHP that requires including a config.php file depending on the
Writing code in PHP, how can I ensure the require_once path of a script
When writing code like this jsLint complains about implied globals: var Test = (function(){
I was writing code in eclipse when a compile error suggested I add exceptions.
I sometimes find myself writing code like this: someFunc :: Foo -> Int someFunc
When writing code sometimes those red error icons pop up on the left side.
I find myself writing code like this in ColdFusion a lot: <cfset inputval =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.