Jump to content
TNG Community
Jan Suhr

Number of people in registry and date of import

Recommended Posts

Jan Suhr

I made a small mod to my index page so that the total number of people in my database is shown together with the date of the last import. 

I don't do any work with my persons i TNG, I just import a GEDCOM from my genealogy program.

The mod is quite simple with two database queries to get the information.
Insert the code below to your templates index.php

//Get number of people
$query = "SELECT count(id) as pcount FROM $people_table";
$result =  tng_query($query) or die ("$text[cannotexecutequery]: $query");
$row = tng_fetch_assoc( $result );
$count = $row['pcount'];

//Get date of import
$dateQuery = "SELECT lastimportdate FROM tng_trees WHERE gedcom = 'tree1'";
$dateResult = tng_query($dateQuery) or die ("$text[cannotexecutequery]: $dateQuery");
$dateRow = tng_fetch_assoc($dateResult);
$stripTime = new DateTime($dateRow['lastimportdate']);
$importdate = $stripTime->format('d M Y');

 You can adjust the date format in various ways that PHP can handle, for example if you want 2020-03-01 you change the format to ('Y-m-d').

Then down on the index page you will place the code to where you want this to be seen.
 

<span class="normal"><b><?php echo $text['js_total_number'] . "<br>" . $count . " " . $text['js_importdate'] . $importdate; ?></b></span><br><br>

In your language files you add this, if you have other languages just add it to your specification.

//English
$text['js_total_number'] = "Total number of people in the registry: ";
$text['js_importdate'] = "after latest data import ";

//Swedish
$text['js_total_number'] = "Antal personer i registret: ";
$text['js_importdate'] = "efter den senaste dataimporten ";

//Danish
$text['js_total_number'] = "Samlet antal personer i registret: ";
$text['js_importdate'] = "efter den seneste dataimport ";


I hope that this will be helpful for some.

Screenshot 2020-02-29 13.23.36.png

Share this post


Link to post
Share on other sites
Newfloridian

We have had a similar function running on our main landing page for many years. I have two trees on board and the result is displayed in a formatted 2 row table table. Roger Moffat provided the TNG code back in the "naughties" and the code also has the commented acknowledgement in the header: created by Roger L. Smith July 2003. The code is included on the page from a standalone php file.

You can see the results about half way down the middle column on this page:

The Extended Craxford Family Web Site

 

(The "Our Most Popular First Names" feature below it is a similar standalone include file)   

Alan

 

 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×