Vise alle undtagen 3 sidste
Hej Eksperter.Jeg har en kode der viser de sidste besøgende på proflierne på vores hjemmeside. Eksempel ses her - under feltet "Mine sidste besøgende - (under udvikling..)":
http://www.phpfusion-tips.dk/profile.php?lookup=1
- jeg har så brugt lidt JavaScript til at få en åbne/lukke-funktion (udvide/sammenklap, eller hvad det nu kaldes, således jeg kan nøjes med at vise f.eks. de 3 sidste besøgende synligt. Når man så trykker på "Flere besøgende..." vil jeg gerne undlade de 3 der jo allerede vises i forvejen.
Jeg ved hvordan man klarer det, hvis man bruger f.eks.:
ORDER BY blabla DESC LIMIT 3,12
Men jeg kan ikke rigtig se mig ud af denne her.. ?
Hjælp påskønnes.
Her kommer koden, der viser sidste besøgende på profilen:
------------------------------------
<?php
//---CONFIG UPPER LEVEL---///
$zw_lastvis_showcount = 2; /// Number of visitors to show !!!!(max 14)!!!!
$daysshown = 5; /// Number of Days, the users are shown
///---CONFIG UPPER LEVEL---///
///---CONFIG LOWER LEVEL---///
$zw_lastvis_showcount2 = 12; /// Number of visitors to show !!!!(max 14)!!!!
$daysshown2 = 14; /// Number of Days, the users are shown
///---CONFIG LOWER LEVEL---///
if ($profile_method == "display") {
$change = false;
$zw_lastvis_array = explode(".",$user_data['zw_lastvisitors']);
if(is_array($zw_lastvis_array) && count($zw_lastvis_array)) {
foreach($zw_lastvis_array as $zwskey => $zwsvals) {
$zwsvals_array = explode("|",$zwsvals);
if ((!isset($zwsvals_array[1]) || $zwsvals_array[1]<(time()-$daysshown*3600*24)) || (iMEMBER && $userdata['user_id'] == $zwsvals_array[0])) { unset($zw_lastvis_array[$zwskey]); $change = true; }
}
}
if (iMEMBER && $userdata['user_id']!=$user_data['user_id']) {
array_unshift($zw_lastvis_array, $userdata['user_id']."|".time());
$change = true;
}
array_splice($zw_lastvis_array,$zw_lastvis_showcount);
if ($change) { $zw_lastivsquery = dbquery("UPDATE ".DB_USERS." SET zw_lastvisitors='".implode(".",$zw_lastvis_array)."' WHERE user_id='".$user_data['user_id']."'"); }
$zw_lastvis_show = "";
$zw_lastvis_none = "Ingen besøgende de sidste 5 dage\n";
if (is_array($zw_lastvis_array) && count($zw_lastvis_array)) {
foreach($zw_lastvis_array as $zw_lastvis_data) {
$zw_lvinfo = explode("|",$zw_lastvis_data);
$zw_lastvis_uname = false;
$zw_lastvis_ava = false;
$zw_lastvis_ava = dbresult(dbquery("SELECT user_avatar FROM ".DB_USERS." WHERE user_id='".$zw_lvinfo[0]."'"),0);
if(isnum($zw_lvinfo[0]) && $zw_lvinfo[0] && $zw_lastvis_uname = dbresult(dbquery("SELECT user_name FROM ".DB_USERS." WHERE user_id='".$zw_lvinfo[0]."'"),0)) {
if ($zw_lastvis_ava['user_avatar']) {
$zw_lastvis_show.=($zw_lastvis_show!="" ? " " : "")."<td align='center' class='tbl1'>\n<table border='1' cellpadding='5' cellspacing='0'>\n<tr>\n<td align='center'><a href='".BASEDIR."profile.php?lookup=".$zw_lvinfo[0]."' title='".$zw_lastvis_uname."'>".$zw_lastvis_uname."<br /><img src='".IMAGES."avatars/".$zw_lastvis_ava."' alt='".$zw_lastvis_uname."' border='0' width='90' /></a></td>\n</td>\n</tr>\n</table>\n";
} else {
$zw_lastvis_show.=($zw_lastvis_show!="" ? " " : "")."<td align='center' class='tbl1'>\n<table border='1' cellpadding='5' cellspacing='0'>\n<tr>\n<td align='center'><a href='".BASEDIR."profile.php?lookup=".$zw_lvinfo[0]."' title='".$zw_lastvis_uname."'>".$zw_lastvis_uname."<br /><img src='".IMAGES."avatars/noav.gif' alt='".$zw_lastvis_uname."' border='0' width='90' /></a></td>\n</td>\n</tr>\n</table>\n";
}
}
}
}
echo "</tr>\n</table>\n";
echo "<div style='margin:5px'></div>\n";
echo "<table cellpadding='0' cellspacing='1' width='580' class='tbl-border center'>\n<tr>\n";
echo "<td class='tbl2' colspan='7'><strong>".$locale['uf_zw_lastvis_03']."</strong></td>\n";
echo "</tr>\n<tr>\n";
if ($zw_lastvis_show=="") {
echo "<td align='right' class='tbl'>".$zw_lastvis_none."</td>\n";
echo "</tr>\n";
}
if ($zw_lastvis_show==!"") {
echo "".$zw_lastvis_show."\n";
echo "</tr>\n<tr>\n";
echo "<td align='right' width='100%' colspan='7' class='tbl'><a href=\"java script:void(0)\" onclick=\"toggle_smt();\"><span id='show_more_threads_text'><b>Flere besøgende...</b></span></a></td>\n";
echo "</tr>\n";
}
// ------------------------------- SPLIT UPPER/LOWER SECTION ------------------------------- //
$change = false;
$zw_lastvis_array = explode(".",$user_data['zw_lastvisitors']);
if(is_array($zw_lastvis_array) && count($zw_lastvis_array)) {
foreach($zw_lastvis_array as $zwskey => $zwsvals) {
$zwsvals_array = explode("|",$zwsvals);
if ((!isset($zwsvals_array[1]) || $zwsvals_array[1]<(time()-$daysshown2*3600*24)) || (iMEMBER && $userdata['user_id'] == $zwsvals_array[0])) { unset($zw_lastvis_array[$zwskey]); $change = true; }
}
}
if (iMEMBER && $userdata['user_id']!=$user_data['user_id']) {
array_unshift($zw_lastvis_array, $userdata['user_id']."|".time());
$change = true;
}
array_splice($zw_lastvis_array,$zw_lastvis_showcount2);
if ($change) { $zw_lastivsquery = dbquery("UPDATE ".DB_USERS." SET zw_lastvisitors='".implode(".",$zw_lastvis_array)."' WHERE user_id='".$user_data['user_id']."'"); }
$zw_lastvis_show = "";
$zw_lastvis_none = "Ingen besøgende de sidste 5 dage\n";
if (is_array($zw_lastvis_array) && count($zw_lastvis_array)) {
foreach($zw_lastvis_array as $zw_lastvis_data) {
$zw_lvinfo = explode("|",$zw_lastvis_data);
$zw_lastvis_uname = false;
$zw_lastvis_ava = false;
$zw_lastvis_ava = dbresult(dbquery("SELECT user_avatar FROM ".DB_USERS." WHERE user_id='".$zw_lvinfo[0]."'"),0);
if(isnum($zw_lvinfo[0]) && $zw_lvinfo[0] && $zw_lastvis_uname = dbresult(dbquery("SELECT user_name FROM ".DB_USERS." WHERE user_id='".$zw_lvinfo[0]."'"),0)) {
if ($zw_lastvis_ava['user_avatar']) {
$zw_lastvis_show.=($zw_lastvis_show!="" ? " " : "")."<td align='center' class='tbl1'>\n<table border='1' cellpadding='5' cellspacing='0'>\n<tr>\n<td align='center'><a href='".BASEDIR."profile.php?lookup=".$zw_lvinfo[0]."' title='".$zw_lastvis_uname."'>".$zw_lastvis_uname."<br /><img src='".IMAGES."avatars/".$zw_lastvis_ava."' alt='".$zw_lastvis_uname."' border='0' width='90' /></a></td>\n</td>\n</tr>\n</table>\n";
} else {
$zw_lastvis_show.=($zw_lastvis_show!="" ? " " : "")."<td align='center' class='tbl1'>\n<table border='1' cellpadding='5' cellspacing='0'>\n<tr>\n<td align='center'><a href='".BASEDIR."profile.php?lookup=".$zw_lvinfo[0]."' title='".$zw_lastvis_uname."'>".$zw_lastvis_uname."<br /><img src='".IMAGES."avatars/noav.gif' alt='".$zw_lastvis_uname."' border='0' width='90' /></a>\n</td>\n</td>\n</tr>\n</table>\n";
}
}
}
}
echo "</tr>\n</table>\n";
echo "<div id='show_more_threads' style='display: none;'>\n";
echo "<table cellpadding='0' cellspacing='1' width='580' class='tbl-border center'>\n<tr>\n";
if ($zw_lastvis_show=="") {
echo "<td align='right' class='tbl'>".$zw_lastvis_none."</td>\n";
echo "</tr>\n";
}
if ($zw_lastvis_show==!"") {
echo "".$zw_lastvis_show."\n";
echo "</tr>\n";
}
echo "</table>\n";
echo "<script type='text/javascript'>
<!--
function toggle_smt() {
var smt = document.getElementById('show_more_threads');
var smttxt = document.getElementById('show_more_threads_text');
if (smt.style.display == 'none') {
smt.style.display = 'block';
smttxt.innerHTML = 'Færre besøgende...';
} else {
smt.style.display = 'none';
smttxt.innerHTML = 'Flere besøgende...';
}
}
//-->
</script>\n
</div>\n";
echo "<table cellpadding='0' cellspacing='0'>\n<tr>\n";
echo "<td></td>\n";
echo "</tr>\n";
}
?>
Fortsat god weekend!
Mvh.
Buxxy.
