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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:44:51+00:00 2026-06-13T11:44:51+00:00

I have a pretty nice system in my code which puts my SQL result

  • 0

I have a pretty nice system in my code which puts my SQL result on different pages, 10 rows on each page. This is great and works exactly the way it should, but I would like to limit the number of pages generated. My result is in a specific order, but after 25 pages I think it’s enough (that would be 250 results). What do I add to the code below in order to maximize the amount of pages created? Thanks in advance!

<?php 

// First I build my SQL which counts the amount of 
// rows, how this SQL query looks like depends on the 
// fields left blank and actually filled.

$sql = "SELECT COUNT(bedrijfsnaam) FROM profiles";

if ($bedrijfvariabele != " zoek op bedrijfsnaam.." && 
    $bedrijfvariabele != "") 
{
    $sql .= " WHERE bedrijfsnaam = '".$bedrijfvariabele."'";
}

if ($rubriekvariabele != " zoek op rubriek.." && 
    $rubriekvariabele != "" && 
    $bedrijfvariabele != " zoek op bedrijfsnaam.." && 
    $bedrijfvariabele != "") 
{
    $sql .= " AND (hoofdrubriek = '" . $rubriekvariabele . "' "
          . " OR subrubrieken LIKE '%" . $rubriekvariabele . "%')";
}

if ($rubriekvariabele != " zoek op rubriek.." && 
    $rubriekvariabele != "" && 
    ($bedrijfvariabele == " zoek op bedrijfsnaam.." || 
     $bedrijfvariabele == "")) 
{
    $sql .= " WHERE (hoofdrubriek = '" . $rubriekvariabele . "' "
          . " OR subrubrieken LIKE '%".$rubriekvariabele."%')";
}

if ($plaatsvariabele != " zoek op plaatsnaam.." && 
    $plaatsvariabele != "" && 
    (
        ($bedrijfvariabele != " zoek op bedrijfsnaam.." && 
         $bedrijfvariabele != "") || 
        ($rubriekvariabele != " zoek op rubriek.." && 
         $rubriekvariabele != "")
    )) 
{
    $sql .= " AND plaats = '".$plaatsvariabele."'";
}

if ($plaatsvariabele != " zoek op plaatsnaam.."  && 
    $plaatsvariabele != "" && 
    (
        ($bedrijfvariabele == " zoek op bedrijfsnaam.." || 
         $bedrijfvariabele == "")  && 
        ($rubriekvariabele == " zoek op rubriek.." || 
         $rubriekvariabele == "")
    )) 
{
    $sql .= " WHERE plaats = '".$plaatsvariabele."'";
}

// Now comes the interesting part for you guys

$rs_result     = mysql_query($sql); 
$row           = mysql_fetch_row($rs_result); 
$total_records = $row[0]; 
$total_pages   = ceil($total_records / 10); 

$template = '<a style="float:none;display:inline-block;color:white;'
          . 'width:22px;text-align:center;text-decoration:none;'
          . 'font-size:20px;background-color:#483435;margin-left:4px"'
          . ' href="%s".php?page=%s">%s</a>'; 


for ($i=1; $i <= $total_pages; $i++) 
{
    echo sprintf($template, $plaatsnaam7, $i, $i); 

}
  • 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-06-13T11:44:52+00:00Added an answer on June 13, 2026 at 11:44 am

    It sounds like you simply need to use a LIMIT keyword on your query.

    Try something like this:
    SELECT * FROM PEOPLE LIMIT 10

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

Sidebar

Related Questions

I have heard that MbUnit comes with pretty nice test decorators which allow writing
I have pretty simple jquery code : $(document).ready(function(){ $('img.marqFl').on({ mouseenter: function() { $(this).animate({height: 300},
I might have pretty basic question about regex. I have the following regex, which
I have built a PHP calendar system and have pretty much everything done but
I have a form, which sets these styles in constructor: this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.UserPaint, true);
I have a pretty nice graph going in canvas right now, but I'm hitting
I have this code (ok, I don't, but something similar :p) var dogs =
I have multiple WCF services pretty much independent one of the other which form
I have pretty good skills in PHP , Mysql and Javascript for a junior
i have pretty simple simple question (i hope so). How do i change 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.