Posted in php functions
2870
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
164
This Month
241
This Year
881

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
Treasure every moment that you have and treasure it more because you shared it with someone special, special enough to spend your time...and remember that time waits for no one.
Unknown
Random CSS Property

inline-size

The inline-size CSS property defines the horizontal or vertical size of an element's block, depending on its writing mode. It corresponds to either the width or the height property, depending on the value of writing-mode.
inline-size css reference