Jump to content

[SOLVED] MySQL Query


whiteboikyle

Recommended Posts

Okay well i am going to be making a members page but i want it to have page numbers. The thing is how do i limit display 20 members per page..

For example on first page will show 1-20 members the second page will show 21-40 members third page will show 41-60 members etc

 

I know its something like

$query = "SELECT * FROM members ORDER BY id desc limit 20";

 

EDIT: i just noticed i posted in wrong place you can delete this if you want!

Link to comment
Share on other sites

Well the way i was thinking of doing it is like this.

Page 1 would have the url members.php?viewlow=1&viewhigh=20

This would display 1-20

Page would have the url members.php?viewlow=21?viewhigh=40

this would display 21-40 and it could somehow use this in the sql

 

like $_GET['viewlow'] , $_GET['viewhigh']

so SELECT * FROM members ORDER BY id desc limit $_GET['viewpage'], $_GET['viewhigh']

 

Is there anyway possible like that?

Link to comment
Share on other sites

After a little hard work and talking to friends online i figured it out

 

<?php
include("header.inc");

if(isset($_GET['page']))
{
$page = $_GET['page'];
if(is_numeric($_GET['page']))
{
	$number = member_start($page);
	$result = $config->query("SELECT * FROM members ORDER BY id desc limit $number,20");
	while( $row = mysql_fetch_array($result) )
		{
			echo("<a href='http://www.corpaluploads.com/".$row['username']."'>".$row['username']."</a><br>");
		}
	}
else
{
	echo "Only Numeric Data May Be Entered!";
}
}
else
{
$number = member_start(1);
$result = $config->query("SELECT * FROM members ORDER BY id desc limit $number,20");
while( $row = mysql_fetch_array($result) )
		{
			echo("<a href='http://www.corpaluploads.com/".$row['username']."'>".$row['username']."</a><br>");
		}
}
include("footer.inc");
?>

 

But now i am working on page numbers on the bottom

I am going to make a function that counts all the members.. Then after that i need to do a  page numbers by consecutive of 20. So if its 20 members or less it needs to be page 1 if its 20-40 members in need to be page 1, 2 but i just gotta think hard about this 1. If you know an easier way or can help me at all let me know ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.