Posted in php functions
2787
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
81
This Month
158
This Year
798

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
When i was a little kid, I was really scared of the dark. But then I came to understand, dark just means the absence of photons in the visible wavelength -- 400 to 700 nanometers. Then i thought, well, its really silly to be afraid of a lack of photons. Then i wasn't afraid of the dark anymore after that.
Elon Musk
Random CSS Property

column-width

The column-width CSS property sets the ideal column width in a multi-column layout. The container will have as many columns as can fit without any of them having a width less than the column-width value. If the width of the container is narrower than the specified value, the single column's width will be smaller than the declared column width.
column-width css reference