Jump to content
TNG Community
swissgenealogy

statistic information without table

Recommended Posts

swissgenealogy

Hi everyboby,

I have tried to use the source code from browsetrees.php to add the statistic information at my index.php.

Unfortunately, as you see here without success:

http://www.swissgenealogy.de/

This is the source code:

<!-- Beginn Statistik -->

<table width="250" border="0" cellspacing="0" cellpadding="0" >

<tr>

<td class="tableheader">

<td class="boxcontent">

<?php

$query = "SELECT count(id) as pcount FROM $people_table $wherestr"; $result = mysql_query($query) or die ($text['cannotexecutequery'] . ": $query"); $row = mysql_fetch_assoc( $result ); $totalpeople = $row['pcount']; mysql_free_result($result);

$totalmedia = array();

foreach( $mediatypes as $mediatype ) {

$mediatypeID = $mediatype['ID'];

if( $tree ) {

$query = "SELECT count(distinct mediaID) as mcount FROM $media_table

WHERE mediatypeID = \"$mediatypeID\" $wherestr2";

}

else

$query = "SELECT count(mediaID) as mcount FROM $media_table WHERE mediatypeID = \"$mediatypeID\"";

$result = mysql_query($query) or die ($text['cannotexecutequery'] . ": $query");

$row = mysql_fetch_assoc( $result );

$totalmedia[$mediatypeID] = number_format($row['mcount']);

mysql_free_result($result);

}

foreach( $mediatypes as $mediatype ) {

$mediatypeID = $mediatype['ID'];

$titlestr = $text[$mediatypeID] ? $text[$mediatypeID] : $mediatypes_display[$mediatypeID];

echo "<tr><td class=\"databack\"><span class=\"normal\">{$text['total']} $titlestr</span></td>\n";

echo "<td class=\"databack\" align=\"right\"><span class=\"normal\">" . $totalmedia[$mediatypeID] . "  </span></td></tr>\n"; }

$query = "SELECT count(id) as scount FROM $sources_table $wherestr"; $result = mysql_query($query) or die ($text['cannotexecutequery'] . ": $query"); $row = mysql_fetch_assoc( $result ); $totalsources = number_format($row['scount']); mysql_free_result($result);

$query = "SELECT personID, firstname, lnprefix, lastname, birthdate, gedcom, living, private, branch

FROM $people_table

WHERE birthdatetr != '0000-00-00' $wherestr2

ORDER BY birthdatetr LIMIT 1";

$result = mysql_query($query) or die ($text['cannotexecutequery'] . ": $query"); $firstbirth = mysql_fetch_array($result); $firstbirthpersonid = $firstbirth['personID']; $firstbirthfirstname = $firstbirth['firstname']; $firstbirthlnprefix = $firstbirth['lnprefix']; $firstbirthlastname = $firstbirth['lastname']; $firstbirthdate = $firstbirth['birthdate']; $firstbirthgedcom = $firstbirth['gedcom']; $firstallowed = determineLivingRights($firstbirth);

mysql_free_result($result);

?>

</td>

</tr>

</table><br/>

<!-- Ende Statistik -->

How can I convert the source code so that the information are NOT displayed in a TABLE, but simple among themselves?

Thanks in advance

And greetings from Switzerland

Ingo

Share this post


Link to post
Share on other sites
JRobison

Hi everyboby,

I have tried to use the source code from browsetrees.php to add the statistic information at my index.php.

Unfortunately, as you see here without success:

http://www.swissgenealogy.de/

This is the source code:

<!-- Beginn Statistik -->

<table width="250" border="0" cellspacing="0" cellpadding="0" >

<tr>

<td class="tableheader">

<td class="boxcontent">

<?php

$query = "SELECT count(id) as pcount FROM $people_table $wherestr"; $result = mysql_query($query) or die ($text['cannotexecutequery'] . ": $query"); $row = mysql_fetch_assoc( $result ); $totalpeople = $row['pcount']; mysql_free_result($result);

$totalmedia = array();

foreach( $mediatypes as $mediatype ) {

$mediatypeID = $mediatype['ID'];

if( $tree ) {

$query = "SELECT count(distinct mediaID) as mcount FROM $media_table

WHERE mediatypeID = \"$mediatypeID\" $wherestr2";

}

else

$query = "SELECT count(mediaID) as mcount FROM $media_table WHERE mediatypeID = \"$mediatypeID\"";

$result = mysql_query($query) or die ($text['cannotexecutequery'] . ": $query");

$row = mysql_fetch_assoc( $result );

$totalmedia[$mediatypeID] = number_format($row['mcount']);

mysql_free_result($result);

}

foreach( $mediatypes as $mediatype ) {

$mediatypeID = $mediatype['ID'];

$titlestr = $text[$mediatypeID] ? $text[$mediatypeID] : $mediatypes_display[$mediatypeID];

echo "<tr><td class=\"databack\"><span class=\"normal\">{$text['total']} $titlestr</span></td>\n";

echo "<td class=\"databack\" align=\"right\"><span class=\"normal\">" . $totalmedia[$mediatypeID] . "  </span></td></tr>\n"; }

$query = "SELECT count(id) as scount FROM $sources_table $wherestr"; $result = mysql_query($query) or die ($text['cannotexecutequery'] . ": $query"); $row = mysql_fetch_assoc( $result ); $totalsources = number_format($row['scount']); mysql_free_result($result);

$query = "SELECT personID, firstname, lnprefix, lastname, birthdate, gedcom, living, private, branch

FROM $people_table

WHERE birthdatetr != '0000-00-00' $wherestr2

ORDER BY birthdatetr LIMIT 1";

$result = mysql_query($query) or die ($text['cannotexecutequery'] . ": $query"); $firstbirth = mysql_fetch_array($result); $firstbirthpersonid = $firstbirth['personID']; $firstbirthfirstname = $firstbirth['firstname']; $firstbirthlnprefix = $firstbirth['lnprefix']; $firstbirthlastname = $firstbirth['lastname']; $firstbirthdate = $firstbirth['birthdate']; $firstbirthgedcom = $firstbirth['gedcom']; $firstallowed = determineLivingRights($firstbirth);

mysql_free_result($result);

?>

</td>

</tr>

</table><br/>

<!-- Ende Statistik -->

How can I convert the source code so that the information are NOT displayed in a TABLE, but simple among themselves?

Thanks in advance

And greetings from Switzerland

Ingo

I'm not exactly sure what you mean but in these lines remove 'class=\"databack\"'.

echo "<tr><td class=\"databack\"><span class=\"normal\">{$text['total']} $titlestr</span></td>\n";

echo "<td class=\"databack\" align=\"right\"><span class=\"normal\">" . $totalmedia[$mediatypeID] . " </span></td></tr>\n";

Jeff

Share this post


Link to post
Share on other sites
theKiwi

In these lines here

echo "<tr><td class=\"databack\"><span class=\"normal\">{$text['total']} $titlestr</span></td>\n";
echo "<td class=\"databack\" align=\"right\"><span class=\"normal\">" . $totalmedia[$mediatypeID] . "  </span></td></tr>\n"; }
remove the
class=\"databack\"

part and see if that gives you what you want. (Wow - beaten by 2 minutes <g>)

Roger

Share this post


Link to post
Share on other sites
JRobison

In these lines here

echo "<tr><td class=\"databack\"><span class=\"normal\">{$text['total']} $titlestr</span></td>\n";
echo "<td class=\"databack\" align=\"right\"><span class=\"normal\">" . $totalmedia[$mediatypeID] . "  </span></td></tr>\n"; }
remove the
class=\"databack\"

part and see if that gives you what you want. (Wow - beaten by 2 minutes <g>)

Roger

Maybe so but your post is better!

Share this post


Link to post
Share on other sites
swissgenealogy

Thank very much you for your quick answers. :-D

Unfortunately, this simply changed the background.

So I've deleted all tr, td, span parts.

The result is now every media statistic in one line.

How do I get these information in different lines?

The final result should look like this:

Total Individuals: 2.878

Photos: 136

Documents: 437

Headstones: 8

Histories: 27

Recordings: 2

Videos: 1

Sources: 224

Earliest Birth (Caspar Gutwein): 23 Jul 1636

I've searched around a bit: might the statistic part of tngtoday2.2 be a solution?

Ingo

Share this post


Link to post
Share on other sites
JRobison

Thank very much you for your quick answers. :-D

Unfortunately, this simply changed the background.

So I've deleted all tr, td, span parts.

The result is now every media statistic in one line.

How do I get these information in different lines?

The final result should look like this:

Total Individuals: 2.878

Photos: 136

Documents: 437

Headstones: 8

Histories: 27

Recordings: 2

Videos: 1

Sources: 224

Earliest Birth (Caspar Gutwein): 23 Jul 1636

I've searched around a bit: might the statistic part of tngtoday2.2 be a solution?

Ingo

It just hit me you don't want lines.

Roger has the correct solution.

Jeff

Share this post


Link to post
Share on other sites
theKiwi

Thank very much you for your quick answers. :-D

Unfortunately, this simply changed the background.

So I've deleted all tr, td, span parts.

The result is now every media statistic in one line.

How do I get these information in different lines?

You could do this

echo "<span class=\"normal\">{$text['total']} $titlestr . ": "  . $totalmedia[$mediatypeID] . "  </span><br />\n"; }

And see what that gives you...

Roger

Share this post


Link to post
Share on other sites
swissgenealogy

Although it dosn´t work properly. But it took me on the to the right way:

 echo "{$text['total']}$titlestr\n: ";
echo "" . $totalmedia[$mediatypeID] . " <br />"; }
And I've also changed the other code to get totalpeople , sources and earliestbirth. But there are only displayed the rusult without the description. What is wrong with the $text parts?

<!-- Beginn Statistik -->
<table width="250" border="0" cellspacing="0" cellpadding="0" >
          <tr>
            <td class="tableheader">
            <td class="boxcontent">
            Datenbankstatistik
            <div class="line"></div>

<?php
// begin totalpeople
$query = "SELECT count(id) as pcount FROM $people_table $wherestr";
$result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query");
$row = mysql_fetch_assoc( $result );
$totalpeople = $row['pcount']; mysql_free_result($result);
    echo "{$text['totindividuals']}\n";
    echo "$totalpeople <br />\n";

// begin media count
$totalmedia = array();
foreach( $mediatypes as $mediatype ) {
    $mediatypeID = $mediatype['ID'];
    if( $tree ) {
        $query = "SELECT count(distinct mediaID) as mcount FROM $media_table
        WHERE mediatypeID = \"$mediatypeID\" $wherestr2";
    }
    else
        $query = "SELECT count(mediaID) as mcount FROM $media_table WHERE mediatypeID = \"$mediatypeID\"";
    $result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query");
    $row = mysql_fetch_assoc( $result );
    $totalmedia[$mediatypeID] = number_format($row['mcount']);
    mysql_free_result($result);
}
foreach( $mediatypes as $mediatype ) {
    $mediatypeID = $mediatype['ID'];
    $titlestr = $text[$mediatypeID] ? $text[$mediatypeID] : $mediatypes_display[$mediatypeID];
    echo "{$text['total']}$titlestr\n: ";
    echo "" . $totalmedia[$mediatypeID] . " <br />"; }

// begin source count
$query = "SELECT count(id) as scount FROM $sources_table $wherestr";
$result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query");
$row = mysql_fetch_assoc( $result ); $totalsources = number_format($row['scount']); mysql_free_result($result);
echo "{$text['totsources']}\n";
echo "$totalsources   <br />";

// begin earliestbirth
$query = "SELECT personID, firstname, lnprefix, lastname, birthdate, gedcom, living, private, branch
    FROM $people_table
    WHERE birthdatetr != '0000-00-00' $wherestr2
    ORDER BY birthdatetr LIMIT 1";
$result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query"); $firstbirth = mysql_fetch_array($result); $firstbirthpersonid = $firstbirth['personID']; $firstbirthfirstname = $firstbirth['firstname']; $firstbirthlnprefix = $firstbirth['lnprefix']; $firstbirthlastname = $firstbirth['lastname']; $firstbirthdate = $firstbirth['birthdate']; $firstbirthgedcom = $firstbirth['gedcom']; $firstallowed = determineLivingRights($firstbirth);
mysql_free_result($result);
echo  $text['earliestbirth'];
if($firstallowed)
    echo " (<a href=\"$getperson_url" . "personID=$firstbirthpersonid&tree=$firstbirthgedcom\">$firstbirthfirstname $firstbirthlnprefix $firstbirthlastname</a>)";
echo " \n";
echo "" . displayDate( $firstbirthdate ) . "  \n";
?>

            </td>
        </tr>
    </table><br/>
<!-- Ende Statistik -->

Ingo

Share this post


Link to post
Share on other sites
JRobison

Although it dosn´t work properly. But it took me on the to the right way:

 echo "{$text['total']}$titlestr\n: ";
echo "" . $totalmedia[$mediatypeID] . " <br />"; }
And I've also changed the other code to get totalpeople , sources and earliestbirth. But there are only displayed the rusult without the description. What is wrong with the $text parts?

<!-- Beginn Statistik -->
<table width="250" border="0" cellspacing="0" cellpadding="0" >
          <tr>
            <td class="tableheader">
            <td class="boxcontent">
            Datenbankstatistik
            <div class="line"></div>

<?php
// begin totalpeople
$query = "SELECT count(id) as pcount FROM $people_table $wherestr";
$result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query");
$row = mysql_fetch_assoc( $result );
$totalpeople = $row['pcount']; mysql_free_result($result);
    echo "{$text['totindividuals']}\n";
    echo "$totalpeople <br />\n";

// begin media count
$totalmedia = array();
foreach( $mediatypes as $mediatype ) {
    $mediatypeID = $mediatype['ID'];
    if( $tree ) {
        $query = "SELECT count(distinct mediaID) as mcount FROM $media_table
        WHERE mediatypeID = \"$mediatypeID\" $wherestr2";
    }
    else
        $query = "SELECT count(mediaID) as mcount FROM $media_table WHERE mediatypeID = \"$mediatypeID\"";
    $result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query");
    $row = mysql_fetch_assoc( $result );
    $totalmedia[$mediatypeID] = number_format($row['mcount']);
    mysql_free_result($result);
}
foreach( $mediatypes as $mediatype ) {
    $mediatypeID = $mediatype['ID'];
    $titlestr = $text[$mediatypeID] ? $text[$mediatypeID] : $mediatypes_display[$mediatypeID];
    echo "{$text['total']}$titlestr\n: ";
    echo "" . $totalmedia[$mediatypeID] . " <br />"; }

// begin source count
$query = "SELECT count(id) as scount FROM $sources_table $wherestr";
$result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query");
$row = mysql_fetch_assoc( $result ); $totalsources = number_format($row['scount']); mysql_free_result($result);
echo "{$text['totsources']}\n";
echo "$totalsources   <br />";

// begin earliestbirth
$query = "SELECT personID, firstname, lnprefix, lastname, birthdate, gedcom, living, private, branch
    FROM $people_table
    WHERE birthdatetr != '0000-00-00' $wherestr2
    ORDER BY birthdatetr LIMIT 1";
$result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query"); $firstbirth = mysql_fetch_array($result); $firstbirthpersonid = $firstbirth['personID']; $firstbirthfirstname = $firstbirth['firstname']; $firstbirthlnprefix = $firstbirth['lnprefix']; $firstbirthlastname = $firstbirth['lastname']; $firstbirthdate = $firstbirth['birthdate']; $firstbirthgedcom = $firstbirth['gedcom']; $firstallowed = determineLivingRights($firstbirth);
mysql_free_result($result);
echo  $text['earliestbirth'];
if($firstallowed)
    echo " (<a href=\"$getperson_url" . "personID=$firstbirthpersonid&tree=$firstbirthgedcom\">$firstbirthfirstname $firstbirthlnprefix $firstbirthlastname</a>)";
echo " \n";
echo "" . displayDate( $firstbirthdate ) . "  \n";
?>

            </td>
        </tr>
    </table><br/>
<!-- Ende Statistik -->
Ingo
A the top of your index.php after <?php add....
$textpart = "stats";

Share this post


Link to post
Share on other sites
theKiwi

Although it dosn´t work properly. But it took me on the to the right way:

 echo "{$text['total']}$titlestr\n: ";
echo "" . $totalmedia[$mediatypeID] . " <br />"; }
Ooops - I missed a " mark I think - this should work
echo "<span class=\"normal\">{$text['total']} $titlestr" . ": "  . $totalmedia[$mediatypeID] . "</span><br />\n"; }

Roger

Share this post


Link to post
Share on other sites
swissgenealogy

I had to experiment a bit, but it's done.

Many thanks, especially to Jeff and Roger !

here is the result:

<?php

// begin totalpeople
$query = "SELECT count(id) as pcount FROM $people_table $wherestr";
$result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query");
$row = mysql_fetch_assoc( $result );
$totalpeople = $row['pcount']; mysql_free_result($result);
    echo "{$text['totindividuals']}: \n";
    echo "$totalpeople <br />\n";

// begin media count
$totalmedia = array();
foreach( $mediatypes as $mediatype ) {
    $mediatypeID = $mediatype['ID'];
    if( $tree ) {
        $query = "SELECT count(distinct mediaID) as mcount FROM $media_table
        WHERE mediatypeID = \"$mediatypeID\" $wherestr2";
    }
    else
        $query = "SELECT count(mediaID) as mcount FROM $media_table WHERE mediatypeID = \"$mediatypeID\"";
    $result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query");
    $row = mysql_fetch_assoc( $result );
    $totalmedia[$mediatypeID] = number_format($row['mcount']);
    mysql_free_result($result);
}
foreach( $mediatypes as $mediatype ) {
    $mediatypeID = $mediatype['ID'];
    $titlestr = $text[$mediatypeID] ? $text[$mediatypeID] : $mediatypes_display[$mediatypeID];
    echo "$titlestr: ";
    echo "" . $totalmedia[$mediatypeID] . "<br />"; }

// begin source count
$query = "SELECT count(id) as scount FROM $sources_table $wherestr";
$result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query");
$row = mysql_fetch_assoc( $result ); $totalsources = number_format($row['scount']); mysql_free_result($result);
echo "{$text['totsources']}: \n";
echo "$totalsources   <br />";

// begin earliestbirth
$query = "SELECT personID, firstname, lnprefix, lastname, birthdate, gedcom, living, private, branch
    FROM $people_table
    WHERE birthdatetr != '0000-00-00' $wherestr2
    ORDER BY birthdatetr LIMIT 1";
$result =  mysql_query($query) or die ($text['cannotexecutequery'] . ": $query"); $firstbirth = mysql_fetch_array($result); $firstbirthpersonid = $firstbirth['personID']; $firstbirthfirstname = $firstbirth['firstname']; $firstbirthlnprefix = $firstbirth['lnprefix']; $firstbirthlastname = $firstbirth['lastname']; $firstbirthdate = $firstbirth['birthdate']; $firstbirthgedcom = $firstbirth['gedcom']; $firstallowed = determineLivingRights($firstbirth);
mysql_free_result($result);
echo  $text['earliestbirth'];
if($firstallowed)
    echo " (<a href=\"$getperson_url" . "personID=$firstbirthpersonid&tree=$firstbirthgedcom\">$firstbirthfirstname $firstbirthlnprefix $firstbirthlastname</a>)";
echo " \n";
echo "" . displayDate( $firstbirthdate ) . "  \n";

?>

shown live at:

http://www.swissgenealogy.de

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

×