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 6003353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:06:33+00:00 2026-05-23T01:06:33+00:00

I have modified my project into a one page website type. Part of the

  • 0

I have modified my project into a one page website type.

Part of the code is this:

for ($i = 1; $i <= $total_pages; $i++)
{                                    
    echo '<a href="view.php?page='.$i.'" data-role="button">'.$i.'</a>';

}

I need that code above to work with an internal link for example:

From here:

echo '<a href="view.php?page='.$i.'" data-role="button">'.$i.'</a>';

TO

echo '<a href="#my-anchor?page='.$i.'" data-role="button">'.$i.'</a>';

Here is the full source code:

$per_page = 6;
$result = mysql_query("SELECT * FROM mytable ORDER BY date DESC");
$total_results = mysql_num_rows($result);
$total_pages = ceil($total_results / $per_page);

if (isset($_GET['page']) && is_numeric($_GET['page']))
{
   $show_page = $_GET['page'];    
   if ($show_page > 0 && $show_page <= $total_pages)
   {
        $start = ($show_page -1) * $per_page;
        $end = $start + $per_page;
   }
   else
   {
        // error - show first set of results
        $start = 0;
        $end = $per_page;
   }                  
}
else
{
   // if page isn't set, show first set of results
      $start = 0;
      $end = $per_page;
}

// display pagination    
echo '<strong>View Page:</strong> ';
echo '<div data-role="controlgroup" data-type="horizontal">';
for ($i = 1; $i <= $total_pages; $i++)
{          
     echo '<a href="view.php?page='.$i.'" data-role="button">'.$i.'</a>';
     //echo '<a href="#view-pag-events" data-role="button">'.$i.'</a>';                
}    
echo '</div>';

I need to change this:

echo '<a href="view.php?page='.$i.'" data-role="button">'.$i.'</a>';

so it’s internal.

  • 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-23T01:06:34+00:00Added an answer on May 23, 2026 at 1:06 am

    Short answer: This can’t be done in PHP alone. You will need send AJAX requests to a PHP script that grabs the data.

    Basically, this will involve creating some javascript that listens for any changes to the hash (that’s the part after the #);

    (function(window) {
        var hash = window.location.hash;
        setTimeout(function() {
            if(window.location.hash !== hash) {
                hash = window.location.hash;
                //Grab and update page with ajax...
            }
            setTimeout(arguments.callee, 50);
        }, 50);
    })(window);
    

    For AJAX basics, check W3Schools. And please, please respect the back button.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this WinForms project (based on this one , but modified for SharePoint
I have modified a website with a redirection to a single page: RewriteCond %{REQUEST_FILENAME}
I have imported an existing Maven project into Eclipse IDE. I modified some of
I am using Ninject in my ASP MVC 3 project, I have modified the
I have a project that's been changed and modified in bits and pieces over
I have modified a slider script to mimic ebay's slider on home page. I
Recently I have modified my code to While taking input form STDIN, I moved
I'm using git for a personal project at the moment and have run into
I'm using PIL for a uni project and we have one task where we
We have been given a little project (As part of my OS course) to

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.