How can I let the user chose how many results they want displayed on a page? For instance they should be able to specify if they want 11, 20, 233 or something to that effect.

Recommended Answers

All 4 Replies

you have to use the limit statement in the query

example:

$sql = 'SELECT * FROM table LIMIT 0, 10';

where 0 is the starting position, which is the beginning and 10 is the user limit you want

you have to use the limit statement in the query

example:

$sql = 'SELECT * FROM table LIMIT 0, 10';

where 0 is the starting position, which is the beginning and 10 is the user limit you want

This will limit my users to 10, but what I want is for the user to be able to tell my database how many records they want displayed at a time.

the number that is limiting the results can be a variable. such as:

The variable $num can contain the number that the user selects.

$num = 10;
$sql = 'SELECT * FROM table LIMIT 0, ' . $num . ';

do you need me to make the selection code as well or can you figure it out?

the number that is limiting the results can be a variable. such as:

The variable $num can contain the number that the user selects.

$num = 10;
$sql = 'SELECT * FROM table LIMIT 0, ' . $num . ';

do you need me to make the selection code as well or can you figure it out?

I think I can figure it out I will let you know if I can't

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.