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
https://forums.phpfreaks.com/topic/110487-solved-mysql-query/
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
https://forums.phpfreaks.com/topic/110487-solved-mysql-query/#findComment-566853
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
https://forums.phpfreaks.com/topic/110487-solved-mysql-query/#findComment-566871
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.