[56K WARN] Mod the way this script works

Looking for volunteers to join your project? Need help with a script but can't afford to pay? Want to offer your services as a volunteer to build up your portfolio? This is the place for you...

Moderator: General Moderators

Post Reply
TheWebJunkie
Forum Newbie
Posts: 1
Joined: Wed Mar 02, 2005 11:42 am

[56K WARN] Mod the way this script works

Post by TheWebJunkie »

Hello guys i was wondering if soem php guru could help me out by adding these new little tweaks to my script

Image

Heres the exsisting code

Code: Select all

<?
require_once("../conn.php");
require_once("access.php");

if(!empty($_GET&#1111;Start]))
&#123;
	$Start = $_GET&#1111;Start];
&#125;
else
&#123;
	$Start = '0';
&#125;

$ByPage = "10";

//get the users list
$q1 = "select * from dd_users order by username limit $Start,$ByPage";
$r1 = mysql_query($q1) or die(mysql_error());

if(mysql_num_rows($r1) == '0')
&#123;
	echo "<br><br><center><font color=red size=2 face=verdana><b>There are no registred users!</b></font></center>";
	exit();
&#125;

?>


<br><br>
<table align=center width=600 cellspacing=0>
<tr style="background-color:#336699; color:white; font-family:verdana; font-size:11; font-weight:bold">
	<td width=200>Username</td>
	<td width=300>Email</td>
	<td width=100 align=center>Action</td>
</tr>

<?
$col = "white";

while($a1 = mysql_fetch_array($r1))
&#123;
	if($col == "white" )
	&#123;
		$col = "#dddddd";
	&#125;
	else
	&#123;
		$col = "white";
	&#125;

	echo "<tr bgcolor=$col>\n\t<td>$a1&#1111;username]</td>\n\t<td>$a1&#1111;email]</td>\n\t<td align=center><a href="EditUser.php?UserID=$a1&#1111;UserID]" class=GreenLink>edit</a> | <a href="DeleteUser.php?UserID=$a1&#1111;UserID]" class=RedLink onclick="return DeleteUser();">delete</a></td>\n</tr>\n\n";

&#125;

echo "</table>\n\n";


//build the "next" - "prev" navigatioin

$qnav = "select * from dd_users";

$rnav = mysql_query($qnav) or die(mysql_error());
$rows = mysql_num_rows($rnav);

		echo  "<br><table align=center width=600>";
		echo "<td align=center><font face=verdana size=2> | ";

		$pages = ceil($rows/$ByPage);

		for($i = 0; $i <= ($pages); $i++)
		&#123;
			$PageStart = $ByPage*$i;

			$i2 = $i + 1;

			if($PageStart == $Start)
			&#123;
				$links&#1111;] = " <span class=DNav>$i2</span>\n\t ";

			&#125;
			elseif($PageStart < $rows)
			&#123;
				$links&#1111;] = " <a class=Nav href=ManageUsers.php?Start=$PageStart>$i2</a>\n\t ";	
			&#125;
		&#125;

		$links2 = implode(" | ", $links);
		


		echo $links2;

		echo  "| </td>";


		echo "</table><br>\n";

?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Moved to PHP - Code from Volunteer.
cbrian
Forum Commoner
Posts: 97
Joined: Sun Feb 27, 2005 12:29 pm

Post by cbrian »

I'm not going to do it for you, but I'll give you a little help.

To get the newest member, do you have a UserID column that is auto_increment for the table? If so, just get the highest one.

To list members from A-Z, put them all into an array and there's a way to sort them alphabetically.

New members this week: My way to do this is a bit strange.

List members by date joined: If you have a column for date joined, just use ORDER BY date_joined

To get Total Members, use mysql_num_rows()
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

To get the newest member, do you have a UserID column that is auto_increment for the table? If so, just get the highest one.

Code: Select all

$sql = "SELECT * FROM `users` ORDER BY `datejoined` DESC LIMIT 1"
Once again, when a user joins, insert the time they have joined
To list members from A-Z, put them all into an array and there's a way to sort them alphabetically.
Not really a need for that, consider you can pull them alphebetically

Code: Select all

$sql = "SELECT * FROM `users` ORDER BY `username` DESC "

Code: Select all

New members this week: My way to do this is a bit strange. 

List members by date joined: If you have a column for date joined, just use ORDER BY date_joined

Code: Select all

$sql = "SELECT * FROM `users` WHERE `datejoined` <= '".strtotime("last week")."' ORDER BY `datejoined` DESC "



All of these are very simple.. not to mention you should store your datejoiend as a unix timestamp
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Moved to Volunteer.

User contacted me, has no prior knowledge of PHP or MYSQL.
Asking for help 8)
Post Reply