php functions
Posted in php functions
2437
10:52 pm, April 12, 2023
 

show views list function

list items by the view count

PHP

function show_views_list($max = 10, $ltype = "top", $ul_class = "", $crop_title_length = true, $interval_len = "1 day") {
	/* get_single_by_uid($field_name,$table_name,$uid,$uid_field_name = "uid") get_link($uid,$p = "view") */
	global $db;
	$out = "";
	if($ltype === "top") {
		$sql = "select * from views order by views desc limit $max";
	}
	if($ltype === "latest") {
		$sql = "select * from views order by insdate desc limit $max";
	}
	if($ltype === "time") {
		$sql = "select * from views where insdate >= date_sub(NOW(), interval $interval_len) order by insdate desc, views desc limit $max";
	}
	$result = $db->query($sql);
	while($row = mysqli_fetch_assoc($result)) {
		$uid = $row['uid'];
		$views = $row['views'];
		$views = restyle_number($views);
		$page_name = get_single_by_uid($field_name = "page_name",$table_name = "pages",$uid,$uid_field_name = "uid");
		
		if($crop_title_length == true) {
			if(strlen($page_name) >= 80 ) {
				$page_name = substr($page_name, 0, 80) . "[..]";
			}
		}
		$page_name_enc = htmlentities($page_name);


		$link = get_link($uid,$p = "view");
		if($page_name > "") {
			$out .= "<li><a href='$link' title='Views $views' ><span class='label'>$views</span> $page_name</a></li>";
		}
	}
	if($ul_class > "") {
		$ul_class = " class='$ul_class'";
	}
	$out = "
	<ul$ul_class>
		$out
	</ul>
	";
	return $out;
}

View Statistics
This Week
49
This Month
120
This Year
604

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
In this case my anchor this week becomes driving almost 2hrs outside of Atlanta to one of my favorite hard core gyms in the world.. MetroFlex aka The Dungeon. The gym owners turn the heat way up so it becomes a fun sweat box and the gym members just watch from afar and leave me alone. I happily drive myself long distances to find MY ANCHOR. Our anchor allows us to have balance, focus and be as productive as possible. And if you're in the middle of a heavy set and your headphones start to fall off your head, like mine did here.. well.. f*ck the headphones. Let em break and fall. You can always get a new pair, but the iron ain't ever gonna lift itself.
Unknown
Random CSS Property

scroll-snap-align

The scroll-snap-align property specifies the box's snap position as an alignment of its snap area (as the alignment subject) within its snap container's snapport (as the alignment container). The two values specify the snapping alignment in the block axis and inline axis, respectively. If only one value is specified, the second value defaults to the same value.
scroll-snap-align css reference