Tutorials
Display most recent members v2
-
Display most recent members v2
Posted on October 12, 2003
Written by
Amy (view more by Amy)
Comments (0)
Filed under Scripts: PHPFanBase, Tutorials
This bit of coding does the same thing as Display Most Recent Members, but you can choose how many members you want to show, and it also works if your fanlisting has fewer than the number of members you’re displaying.
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.
<?php $numtoshow = 5; ?>
<p>Last Added: <strong>
<?php include_once("config.php");
$last_query = "SELECT * FROM $table WHERE apr='y' order by id DESC limit $numtoshow";
$last_result = mysql_query($last_query);
$last_num = mysql_numrows($last_result);
$i = 0;
while ($i < $last_num) {
$name=mysql_result($last_result,$i,"name");
$url=mysql_result($last_result,$i,"url");
$email=mysql_result($last_result,$i,"email");
if ($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 == $last_num - 2) {
echo ", and ";
} elseif ($i == $last_num - 1) {
echo ".";
} else {
echo ", ";
}
$i++;
} ?>
</strong></p>
Change the variable at the top, $numtoshow to any number greater than 0. So if you want to show the 3 latest members, change it to 3.
Comments
Comments are closed for this entry.