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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:04:32+00:00 2026-05-14T15:04:32+00:00

Hey, I want to add a button(link), that when clicked will filter the pagination

  • 0

Hey, I want to add a button(link), that when clicked will filter the pagination results.

I’m new to php (and programming in general) and would like to add a button like ‘Automotive’ and when clicked it updates the 2 mysql queries in my pagination script, seen here:

As you can see, the category automotive is hardcoded in, I want it to be dynamic, so when a link is clicked it places whatever the id or class is in the category part of the query.

1:

$record_count = mysql_num_rows(mysql_query("SELECT * FROM explore WHERE category='automotive'"));

2:

$get = mysql_query("SELECT * FROM explore WHERE category='automotive' LIMIT $start, $per_page");

This is the entire current php pagination script that I am using:

<?php

    //connecting to the database
    $error = "Could not connect to the database";
    mysql_connect('localhost','root','root') or die($error);
    mysql_select_db('ajax_demo') or die($error);

    //max displayed per page
    $per_page = 2;

    //get start variable
    $start = $_GET['start'];

    //count records
    $record_count = mysql_num_rows(mysql_query("SELECT * FROM explore WHERE category='automotive'"));

    //count max pages
    $max_pages = $record_count / $per_page; //may come out as decimal

    if (!$start)
       $start = 0;

    //display data
    $get = mysql_query("SELECT * FROM explore WHERE category='automotive' LIMIT $start, $per_page");
    while ($row = mysql_fetch_assoc($get))
    {
     // get data
     $name = $row['id'];
     $age = $row['site_name'];

     echo $name." (".$age.")<br />";

    }

    //setup prev and next variables
    $prev = $start - $per_page;
    $next = $start + $per_page;

    //show prev button
    if (!($start<=0))
           echo "<a href='pagi_test.php?start=$prev'>Prev</a> ";

    //show page numbers

    //set variable for first page
    $i=1;

    for ($x=0;$x<$record_count;$x=$x+$per_page)
    {
     if ($start!=$x)
        echo " <a href='pagi_test.php?start=$x'>$i</a> ";
     else
        echo " <a href='pagi_test.php?start=$x'><b>$i</b></a> ";
     $i++;
    }

    //show next button
    if (!($start>=$record_count-$per_page))
           echo " <a href='pagi_test.php?start=$next'>Next</a>";

    ?>
  • 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-14T15:04:32+00:00Added an answer on May 14, 2026 at 3:04 pm

    Example with 2 links/categories:

    <a href='script.php?category=automotive'>automotive</a> <a href='script.php?category=sports'>sports</a>
    

    Inside script.php:

    $category = mysql_real_escape_string($_GET['category']);
    $record_count = mysql_num_rows(mysql_query("SELECT * FROM explore WHERE category='$category'"));
    ...
    $get = mysql_query("SELECT * FROM explore WHERE category='$category' LIMIT $start, $per_page");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I want to Fetch the date from the date picker and add that
Hey guys, I'm trying to add a textfield.text entry to an array. I want
Hey I want to select records with name O'Neil, How can i do that
Hey i dont know if that is possible but i want to set a
Hey guys, I got this JS code and want to add a slight fade
Hey! I have matrix class and i want to add, multiply and take transpose
I am creating an image viewer, and I want add an entry to Hey
Hey So I'm pretty much awful at java and I want to add a
Hey is there anyway that in your program you can add a minimize/ maximize
Hey, I want to add custom buttom to the django admin site, and the

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.