Tutorials

Display most recent members

This bit of coding will display the last 5 members approved for your fanlisting like this:
Last Added: Anne, Anna, Annie, Ann and Bonnie.
If they submitted a website, their name will be linked to their site, if they didn’t, their name will be linked to their (SPAM protected) email address.

Paste the following into the page you want to display this on. It must have a .php extension and reside in the same directory as the config.php file for your fanlisting.

<p>Last Added: <b>
<?php include_once "config.php";
$last_query = "SELECT * FROM $table WHERE apr='y' order by id DESC limit 5";
$last_result = mysql_query($last_query);

while($last_row = mysql_fetch_array($last_result)) {
$i = 0;
$name = $last_row['name'];
$url = $last_row['url'];
$email = $last_row['email'];

if (!empty($url)) { ?>
<a href="<?php echo $url; ?>" target="_blank"><?php echo $name; ?></a>

<?php } else { ?>
<script type="text/javascript">
emailE=('<?php echo $email; ?>')
document.write(
'<a href="mailto:' + emailE + '">'
+ '<?php echo $name; ?>' +'</a>'
)</script>

<?php } if ($i == 0 || $i == 1 || $i == 2) {
echo ", "; }
elseif ($i == 3) {
echo ", and ";
} elseif ($i == 4) {
echo "."; }
$i++;
} ?>
</strong></p>

Comments

Error Comments are closed for this entry.