Posted in php functions
2694
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
24
This Month
167
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
“If you just sit and observe, you will see how restless your mind is. If you try to calm it, it only makes it worse, but over time it does calm, and when it does, there’s room to hear more subtle things. You see so much more than you could see before. It’s a discipline; you have to practice it.”
Steve Jobs
Random CSS Property

accent-color

The accent-color CSS property sets the accent color for user-interface controls generated by some elements.
accent-color css reference