Tutorials
Show all members added with last update
-
Show all members added with last update
Posted on October 15, 2003
Written by
Sasha (view more by Sasha)
Comments (0)
Filed under Scripts: PHPFanBase, Tutorials
This add-on script, written by Skybly, will display all the members you added with the last update. More specifically, it will determine the last day you added a member, and show all other members you added on the same day; so it would work best for a fanlisting that adds a medium batch of members every update (more than 3 but probably less than 20).
A small change to the DB is required, so you might want to backup the DB and the files that are to be edited. In case this turns out to be incompatible with future versions of PHPfanbase, it’s easy to remove it again, though.
-
Log into your phpyAdmin and open the table that stores your fanlisting’s member information (the one you set up as $table in config.php).
-
Find the “add new field” function, and add one new field at the end of the table. Call this field apr_date and set the type to DATE.
-
In join.php, find this part at around line 331:
if ($enablefave == 'Y'){ $query = "INSERT INTO $table VALUES ('','$name','$email','$url','$country','$comments', '$hideemail','$apr','$fave')"; mysql_query($query); } else { $query = "INSERT INTO $table VALUES ('','$name','$email','$url','$country','$comments', '$hideemail','$apr')"; mysql_query($query); }and change it to:
if ($enablefave == 'Y'){ $query = "INSERT INTO $table VALUES ('', '$name', '$email', '$url', '$country', '$comments', '$hideemail', '$apr', '$fave', '')"; mysql_query($query); } else { $query = "INSERT INTO $table VALUES ('', '$name', '$email', '$url', '$country', '$comments', '$hideemail', '$apr', '')"; mysql_query($query); } -
In admin.php, find this part around line 80:
if ($enablefave == 'Y'){ $query = "UPDATE $table SET name='$name', email='$email', url='$url', country='$country', comments='$comments', hideemail='$hideemail', apr='y', fave='$fave' WHERE id='$id'"; } else { $query = "UPDATE $table SET name='$name', email='$email', url='$url', country='$country', comments='$comments', hideemail='$hideemail', apr='y' WHERE id='$id'"; }and change it to:
if ($enablefave == 'Y'){ $query = "UPDATE $table SET name='$name', email='$email', url='$url', country='$country', comments='$comments', hideemail='$hideemail', apr='y', fave='$fave', apr_date=NOW() WHERE id='$id'"; } else { $query = "UPDATE $table SET name='$name', email='$email', url='$url', country='$country', comments='$comments', hideemail='$hideemail', apr='y', apr_date=NOW() WHERE id='$id'"; } -
Now you can add this snippet to your intro page (where you are displaying current number of members, last update etc.):
Welcome, <?php include("config.php"); $query = "SELECT MAX(apr_date) FROM $table"; $result = mysql_query($query); $last_approved = mysql_result($result, 0, 'MAX(apr_date)'); $query = "SELECT name, url FROM $table WHERE apr='y' AND apr_date='$last_approved'"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { if ($row['url'] != 'http://' && $row['url'] != '') { $latest_members[] = "<a href=\"{$row['url']}\">{$row['name']}</a>"; } else { $latest_members[] = $row['name']; } } $latest_member = array_pop($latest_members); if (count($latest_members) == 0) { echo $latest_member; } else { echo implode(', ', $latest_members) . ' and ' . $latest_member; } ?> !
Comments
Comments are closed for this entry.