Posted in php functions
2715
10:48 pm, April 12, 2023
 

list page links function list_page_links

list top number of page links from selected table

test run time on db of 4k items. 

select * from pages where publish = 'publish' order by insdate desc limit 10
10 rows (0.005 s)

PHP

/* list page links */
function list_page_links($publish = "publish",$max = 10, $list_style = "div", $start = 0, $crop_title_length = false) {
	global $db;
	$out = "";
	$sql = "select * from pages where publish = '$publish' order by insdate desc limit $start, $max ";
	$result = $db->query($sql);
	if(!$result) { return "No Pages Found"; }
	while($row = mysqli_fetch_assoc($result)) {	
		$id = $row['id'];
		$uid = $row['uid'];
		$page_name = politeify($row['page_name']);

		if($crop_title_length == true) {
			if(strlen($page_name) >= 80 ) {
				$page_name = substr($page_name, 0, 80) . "[..]";
			}
		}

		$page_link = get_link($uid,$p = "view");
		if($list_style == "div") {
			$out .= "
			<div class='page_link clickable'>
				<a href='$page_link'><i class='fa fa-angle-double-right'></i> $page_name</a>
				<div class='mplus'><i class='fa fa-plus-square'></i></div>
			</div>
			";
		} else if ($list_style == "li") {
			$out .= "
			<li>
				<a href='$page_link'>$page_name</a>
			</li>
			";
		}
	}
	if(!($out > "")) {
		$out = "No Pages Found";
	}
	return $out;
}

View Statistics
This Week
27
This Month
86
This Year
726

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
You want to be the best, you MUST put the long yards in! Nothing comes easy in life so stop wishing and start DOING! So many people would rather bitch and moan than help themselves. Dont be one of those negative drainers, start today, make a small change and keep going forwards with this attitude!
Unknown
Random CSS Property

sepia()

The sepia() CSS function converts the input image to sepia, giving it a warmer, more yellow/brown appearance. Its result is a <filter-function>.
sepia() css reference