Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Admin View Members Page
Old 07-16-2010, 03:37 PM Admin View Members Page
Skilled Talker

Posts: 83
Trades: 0
I am currently working on an admin only page that allows the admin to view all of the websites members. On this page, the admin can edit any of the information for the users (and change it in the database), delete the users, ban the users, and sort the users (depending on which link they press, it will sort it accordingly).

I've got the basic layout complete, however I have run into some dead ends.
First Issue:
I have the users information split into two different tables in my database. The first one "users" contains their basic information (name, username, email), while the second "userstats" contains their stats (credits, level, etc). Right now, when the page is loaded, it goes through the "users" table and displays each row exactly how it should. But I need it to do the same thing on these same rows for the other table. I'm not sure how I should change my While loop to get it to do this without causing problems.

Second Issue:
The sort feature allows the admin to sort through all the information by the username, id, email, etc. It works perfectly in an Ascending order, but I want it to go the opposite direction (Descending) once it is clicked again. I tried setting variables, and adding increment each time the link was clicked, and determining if the variable contained an even or odd number, but this didn't seem to work (The variable stayed at 1, so I obviously did it wrong).

Third Issue:
I need there to be a Delete button which when clicked, will popup a javascript confirm window. Once the admin confirms they want to delete the user, it will erase their information.

Any feedback on any of these issues would be greatly appreciated.

Here is my code:

PHP Code:
<?php
session_start
();
include_once(
'../inc/connect.php');

$result mysql_query("SELECT * FROM users ORDER BY id");

$today date("Y-m-d");

$sort $_GET['sort'];
$delete $_GET['delete'];
$submit $_POST['submit'];

if (
$sort==id){ 

    
$result mysql_query("SELECT * FROM users ORDER BY id");  
 
}
if (
$sort==username){ 

$result mysql_query("SELECT * FROM users ORDER BY username"); 
 
}
if (
$sort==email){ 

$result mysql_query("SELECT * FROM users ORDER BY email"); 
 
}
if (
$sort==type){ 

$result mysql_query("SELECT * FROM users ORDER BY member"); 
 
}
if (
$sort==referrer){ 

$result mysql_query("SELECT * FROM users ORDER BY referrer"); 
 
}
if (
$sort==level){ 

$result mysql_query("SELECT * FROM userstats ORDER BY level"); 
 
}
if (
$sort==exp){ 

$result mysql_query("SELECT * FROM userstats ORDER BY exp"); 
 
}
if (
$sort==credits){ 

$result mysql_query("SELECT * FROM userstats ORDER BY credits"); 
 
}

if (
$delete==true){

mysql_query("DELETE * from exampletable");

}

if (
$ban==true){



}
// head
echo "
<html>
<head>
<title>Users</title>
<style>
a:link{
text-decoration: none;
color: #519904;
}
a:visited{
text-decoration: none;
color: #519904;
}
a:hover{
text-decoration: none;
color: #4296ce;
}
#joined{
position: absolute;
width: 200px;
top: 35px;
left: 465px;
}
</style>
</head>
<body>
"
;
echo 
"<h2 align='center'>Members</h2><br /><table border='1' align='center'>
<tr>
<th bgcolor='#cccccc'><a href='users.php?sort=id'>ID</a></th>
<th bgcolor='#cccccc'><a href='users.php?sort=username'>Username</a></th>
<th bgcolor='#cccccc'><a href='users.php?sort=email'>Email</a></th>
<th bgcolor='#cccccc'><a href='users.php?sort=type'>Type</a></th>
<th bgcolor='#cccccc'><a href='users.php?sort=referrer'>Referrer</a></th>

<!-- Level, Exp, and Credits are in the table called userstats -->

<th bgcolor='#cccccc'><a href='users.php?sort=level'>Level</a></th>
<th bgcolor='#cccccc'><a href='users.php?sort=exp'>Exp</a></th>
<th bgcolor='#cccccc'><a href='users.php?sort=credits'>Credits</a></th>
</tr><form>"
;
$recentmembers 0;
while(
$row mysql_fetch_array($result))
  {
  
$joined $row['joindate'];
  if (
$joined==$today){
  
$recentmembers += 1;
  }
  echo 
"<tr>";
  echo 
"<td align='center' width='40'>" .$row['id']. "</td>";
  echo 
"<td align='center' width='130'><input type='text' name='username' value='" .$row['username']. "'></td>";
  echo 
"<td align='center' width='230'><input type='text' name='email' value='" .$row['email']. "' size='35'></td>";
  echo 
"<td align='center' width='10'><input type='text' name='member' value='" .$row['member']. "' size='2'></td>";
  echo 
"<td align='center' width='175'><input type='text' name='referrer' value='" .$row['referrer']. "' size='25'></td>";
  echo 
"<td align='center' width='10'><input type='text' name='level' value='" .$row['level']. "' size='2'></td>";
  echo 
"<td align='center' width='10'><input type='text' name='exp' value='" .$row['exp']. "' size='10'></td>";
  echo 
"<td align='center' width='10'><input type='text' name='credits' value='" .$row['credits']. "' size='20'></td>";
  echo 
"<td align='center' width='10'><a href='users.php?delete=true&id=" .$row['id']. "'>Delete</a></td>";
  
  echo 
"</tr>";
  }
 
echo 
"</table><br /><center><input type='submit' name='submit' value='Submit Changes'><input type='reset' name='reset' value='Reset'></form></center>";
echo 
"<br /><div id='joined'>Joined Today: ".$recentmembers."</div>";

// Footer
echo "
</body>
</html>
"
;

// Change User's Information

if (isset($submit)){

    
// UPDATE USERS INFORMATION FOR ONLY THE ROWS THAT HAVE BEEN MODIFIED


}

?>
Smudly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-16-2010, 04:33 PM Re: Admin View Members Page
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://www.codetoad.com/javascript/f...irm_delete.asp

for reversing the order set a flag in a session variable, because if you simply set a variable it will be lost each time the page is submitted.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Admin View Members Page
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10175 seconds with 12 queries