Posted in php functions
2719
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
31
This Month
90
This Year
730

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
A.A. Milne’s Winnie-the-Pooh: “If you live to be a hundred, I want to live to be a hundred minus one day so I never have to live without you.”
A.A. Milne
Random CSS Property

<display-legacy>

CSS 2 used a single-keyword syntax for the display property, requiring separate keywords for block-level and inline-level variants of the same layout mode. This page details those values.
<display-legacy> css reference