Location: PHPKode > projects > ConPortal > conportal/inc/links/db.php
<?php
// Functions pertaining to the table link_list and link_groups in the database
// John Duprey


function getLinkList($gid) {  // gets all the links from a certian link group, returns an array
	$query = 'select link,title,id from link_list where gid = %d order by list_order asc';
	$linklist = safeQuery($query, $gid);
	while ($row = mysql_fetch_assoc($linklist)) {
		$array[] = $row;
	}
	return $array;
}

function getLinkGroups() {  // returns an array of the link groups
	$query = 'select id,name from link_groups';
	$grouplist = safeQuery($query);
	while ($row = mysql_fetch_assoc($grouplist)) {
		$array[] = $row;
	}
	return $array;
}

function getPopularLinks() { // determines which links have been clicked on the most and displays them in order
	$query = 'select id,link,title,clicks from link_list order by clicks desc limit 5';
	$poplist = safeQuery($query);
	while ($row = mysql_fetch_assoc($poplist)) {
	$array[] = $row;
	}
	return $array;
}

function updatePopular($id) { // database side of an ajax call to increase the click count on a link
	$query = 'select clicks from link_list where id = %d limit 1';
	$res = safeQuery($query, $id);
	$row = mysql_fetch_assoc($res);
	$click = $row['clicks'] + 1;
	$query2 = "update link_list set clicks = %d where id = %d";
	safeQuery($query2, $click, $id);
}

?>
Return current item: ConPortal