Jump to content

members page

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
okay well i am making a members page and i will be using the query
SELECT * FROM members ORDER BY id desc limit $_GET['page'], member_start($page)

Here is the function for member_start($page);
<?php


function member_start($page)

{

	if($page < 1)

	{

		$error = "Number must be greater then 1!";

		return $error;

	}

	$number = ($page * 20)-19;

	return $number;


}


?>

So on my members.php page i have this so far

<?php

include("header.inc");


if(isset($_GET['page']))

{

	if($_GET['page'] == 

}


include("footer.inc");

?>

but what i am doing is first Make sure that $_GET['page'] is set then i want to make sure its a Interger (where i am stuck at).

#2
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
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 ;)

#3
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Only took you 28 minutes to solve! Nice work!

#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
is_numeric not only matches integers, but ALL numbers (doubles, floats, and hex numbers), this may not be ideal for your situation. You are probably better off using preg_match.

#5
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
Really!! ooh thanks! i will do that lol.. but uhhhh does anyone know how to setup page's i mean i have the mathematics's solved for it.

Edited by Whitey, 17 June 2008 - 05:49 PM.


#6
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
I must be getting better or something! lol i solved it.. Took me a little longer!
function.php
function page_numbers($members)
{
$number = $members/20;
	if(is_int($number))
	{
		for ($i=0;$i<$number;$i++)
		{
			echo("<a href='?page=".$i."'>$i</a>");
		}
	}
	else
	{
		$number = floor($number);
		$number = $number + 2;
		for ($i=0;$i<$number;$i++)
		{
			if($i == 0)
			{
			continue;
			}
			echo("<a href='?page=".$i."'>$i </a>");
		}
	}

}

memebers.php
$result = $config->query("SELECT * FROM members");
$members = mysql_num_rows($result);
echo("<br><br><div align='center'>Page: ");
page_numbers($members);
echo(" </div>");