Location: PHPKode > projects > HuMo-gen > lijst_namen.php
<?php
$kop="index";
include("header.php");

//*** Namen lijst *****************************************************************************
include("menu.php");

//TWEE KEER een <p> item??
echo '<p class="fonts">';

	//*** Find first letter of last name ***
	print "<p align=center>";
	$persoonqry="SELECT UPPER(substring(pers_lastname,1,1)) as letter FROM ".veilig($_SESSION['tree_prefix'])."person GROUP BY letter";
	// *** Voor "van Mons", ook pers_prefix zoeken ***
	if ($user['soortindex']=="j"){
		$persoonqry="SELECT UPPER(substring(CONCAT(pers_prefix,pers_lastname),1,1)) as letter
		FROM ".veilig($_SESSION['tree_prefix'])."person GROUP BY letter";
	}
	@$persoon=mysql_query($persoonqry, $db);
	while (@$personDb=mysql_fetch_object($persoon)){
		$letter[$personDb->letter]=$personDb->letter; }
	for ($i=1; $i<=26; $i++) {
		$letter2=chr($i+64); //chr(65)=A
		if (isset($letter[$letter2])){
			// *** url_rewrite ***
			if ($humo_option["url_rewrite"]=="j"){
				// *** $uri_pad is gemaakt in header.php ***
				//echo ' <a href="'.$uri_pad.'lijst_namen/'.$_SESSION['tree_prefix'].'/alfabet/'.$letter2.'/">'.$letter2.'</a>';
				echo ' <a href="'.$uri_pad.'lijst_namen/'.$_SESSION['tree_prefix'].'/'.$letter2.'/">'.$letter2.'</a>';
			}
			else{
				print ' <a href="lijst_namen.php?database='.$_SESSION['tree_prefix'].
				'&amp;last_name='.$letter2.'">'.$letter2.'</a>';
			}
		}
		else{
			print ' <b>'.$letter2.'</b>';
		}
	}
	//echo " <a href=\"lijst_namen.php?last_name=...\">".$language["main_other"]."</a>\n";

	echo " <a href=\"lijst_namen.php?last_name=all\">".$language["main_all"]."</a>\n";
	echo '</p>';

// *** Alphabet find first letter of lastname ***
$last_name='a'; // *** Default letter ***
// *** Variabelen zoeken in: http://localhost/humo-gen/lijst/humo1_/alfabet/M/ ***
if (isset($urlpart[1])){
	$last_name=veilig($urlpart[1]);
}
if (isset($_GET['last_name'])){
	$last_name=veilig($_GET['last_name']);
}

echo '<div class="index_lastname">';

// Mons, van of: van Mons
if ($user['soortindex']=="j"){
	$persoon=mysql_query("SELECT pers_lastname, pers_prefix,
		CONCAT(pers_prefix,pers_lastname) as totaalnaam, count(pers_lastname) as aantal
		FROM ".veilig($_SESSION['tree_prefix'])."person
		WHERE CONCAT(pers_prefix,pers_lastname) LIKE '".$last_name."%'
		GROUP BY totaalnaam",$db);

	if ($last_name=='all'){
		$persoon=mysql_query("SELECT pers_lastname, pers_prefix,
			CONCAT(pers_prefix,pers_lastname) as totaalnaam, count(pers_lastname) as aantal
			FROM ".veilig($_SESSION['tree_prefix'])."person GROUP BY totaalnaam",$db);
	}

	while (@$personDb=mysql_fetch_object($persoon)){
		//Een & teken mag niet meegestuurd worden in de GET, dus een replace naar | !!!
		$totaalnaam=str_replace("_", " ", $personDb->totaalnaam);
		if ($totaalnaam=="doodgeboren kind"){ $totaalnaam=$language["pers_stillborn_child"]; }
		if ($totaalnaam){
			$link=str_replace("_", " ", $personDb->pers_prefix).$personDb->pers_lastname;
			$link=str_replace("&", "|", $link);
			$naam=$totaalnaam;
		}
		else{
			$link=$language["pers_unknown_lastname"];
			//$pers_prefix=''; //if ($personDb->pers_prefix){ $pers_prefix='&pers_prefix='.$personDb->pers_prefix; }
			$naam=$language["pers_unknown_lastname"];
		}

		echo '<a href="lijst.php?database='.$_SESSION['tree_prefix'].'&amp;pers_lastname='.$link;
		echo '&amp;zoekdeelpers_lastname=gelijk';
		echo '">'.$naam.'</a> ('.$personDb->aantal.')'.$dirmark2.' / '.$dirmark2.' ';
	}
}
else{
	// *** Select alphabet letter ***
	$persoon=mysql_query("SELECT pers_lastname, pers_prefix,
		CONCAT(pers_lastname,pers_prefix) as totaalnaam, count(pers_lastname) as aantal
		FROM ".veilig($_SESSION['tree_prefix'])."person
		WHERE pers_lastname LIKE '".$last_name."%'
		GROUP BY totaalnaam
		",$db);

	if ($last_name=='all'){
		$persoon=mysql_query("SELECT pers_lastname, pers_prefix,
		CONCAT(pers_lastname,pers_prefix) as totaalnaam, count(pers_lastname) as aantal
		FROM ".veilig($_SESSION['tree_prefix'])."person
		GROUP BY totaalnaam",$db);
	}

	while (@$personDb=mysql_fetch_object($persoon)){
		// *** Een & teken mag niet meegestuurd worden in de GET, dus een replace naar | !!! ***
		$pers_lastname=$personDb->pers_lastname;
		if ($personDb->pers_prefix){ $pers_lastname.=', '.$personDb->pers_prefix; }
		$pers_lastname=str_replace("_", " ", $pers_lastname);
		if ($pers_lastname=="doodgeboren kind"){ $pers_lastname=$language["pers_stillborn_child"]; }
		if ($pers_lastname){
			$link=$personDb->pers_lastname;
			$link=str_replace("&", "|", $link);
			$pers_prefix='';
			if ($personDb->pers_prefix){
				$pers_prefix=$personDb->pers_prefix;
			}
			else{
				$pers_prefix='LEEG';
			}
			$naam=$pers_lastname;

		}
		else{
			$link=$language["pers_unknown_lastname"];
			$pers_prefix=''; //if ($personDb->pers_prefix){ $pers_prefix='&amp;pers_prefix='.$personDb->pers_prefix; }
			$naam=$language["pers_unknown_lastname"];
		}

		echo '<a href="lijst.php?database='.$_SESSION['tree_prefix'].'&amp;pers_lastname='.$link;
		if ($pers_prefix){ echo '&amp;pers_prefix='.$pers_prefix; }
		echo '&amp;zoekdeelpers_lastname=gelijk';
		echo '">'.$naam.'</a> ('.$personDb->aantal.')'.$dirmark2.' / '.$dirmark2.' ';
	}
}

echo '</div>';

//mysql_close($db); //databaseverbinding sluiten.
include("footer.php");
?>
Return current item: HuMo-gen