php functions
Posted in php functions
2538
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
109
This Month
221
This Year
705

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
I'm a big believer in energy and the secret and that sort of thing.
Unknown
Random CSS Property

repeating-radial-gradient()

The repeating-radial-gradient() CSS function creates an image consisting of repeating gradients that radiate from an origin. It is similar to radial-gradient() and takes the same arguments, but it repeats the color stops infinitely in all directions so as to cover its entire container, similar to repeating-linear-gradient(). The function's result is an object of the <gradient> data type, which is a special kind of <image>.
repeating-radial-gradient() css reference