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
TheWebJunkie
Forum Newbie
Posts: 1 Joined: Wed Mar 02, 2005 11:42 am
Post
by TheWebJunkie » Wed Mar 02, 2005 11:46 am
Hello guys i was wondering if soem php guru could help me out by adding these new little tweaks to my script
Heres the exsisting code
Code: Select all
<?
require_once("../conn.php");
require_once("access.php");
if(!empty($_GETїStart]))
{
$Start = $_GETїStart];
}
else
{
$Start = '0';
}
$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')
{
echo "<br><br><center><font color=red size=2 face=verdana><b>There are no registred users!</b></font></center>";
exit();
}
?>
<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))
{
if($col == "white" )
{
$col = "#dddddd";
}
else
{
$col = "white";
}
echo "<tr bgcolor=$col>\n\t<td>$a1їusername]</td>\n\t<td>$a1їemail]</td>\n\t<td align=center><a href="EditUser.php?UserID=$a1їUserID]" class=GreenLink>edit</a> | <a href="DeleteUser.php?UserID=$a1їUserID]" class=RedLink onclick="return DeleteUser();">delete</a></td>\n</tr>\n\n";
}
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++)
{
$PageStart = $ByPage*$i;
$i2 = $i + 1;
if($PageStart == $Start)
{
$linksї] = " <span class=DNav>$i2</span>\n\t ";
}
elseif($PageStart < $rows)
{
$linksї] = " <a class=Nav href=ManageUsers.php?Start=$PageStart>$i2</a>\n\t ";
}
}
$links2 = implode(" | ", $links);
echo $links2;
echo "| </td>";
echo "</table><br>\n";
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Mar 02, 2005 11:54 am
Moved to PHP - Code from Volunteer.
cbrian
Forum Commoner
Posts: 97 Joined: Sun Feb 27, 2005 12:29 pm
Post
by cbrian » Wed Mar 02, 2005 5:49 pm
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()
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Mar 02, 2005 6:49 pm
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
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Mar 02, 2005 7:14 pm
Moved to Volunteer.
User contacted me, has no prior knowledge of PHP or MYSQL.
Asking for help