Display total number of pictures in gallery? Display total number of pictures in gallery?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Display total number of pictures in gallery?

Started by jan_64, January 09, 2008, 09:30:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jan_64

I would like to display the total number of pictures in my gallery (www.jangaeblerphoto.de) on the start page. I want to place it in the welcome text, that I have added in the template.html.

How can I get it? I only found a solution to display it in an external website (http://forum.coppermine-gallery.net/index.php?topic=26227.msg120914#msg120914).

Thanks for any help!

just_some_guy

#1

<?php
$result 
cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PREFIX']}pictures");
$num_files mysql_num_rows($result);

echo 
$num_files;

?>


I suggest using anycontent.php though, as it would be easier to implement PHP.
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Joachim Müller

@just_some_guy: I understand that you're trying to help, but I told you before already: don't use proprietary mysql query syntax, but the one built into coppermine...

just_some_guy

Quote from: Joachim Müller on January 10, 2008, 08:17:58 AM
@just_some_guy: I understand that you're trying to help, but I told you before already: don't use proprietary mysql query syntax, but the one built into coppermine...

Sorry about that, i forgot. I have corrected my original posting.
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

jan_64

 ??? Could you please explain this code for a php newbie? I would like to appear the number in my introduction text, that I put into the html-template. Can put this code into the html template? How can I use anycontent.php for this?
Do I have to replace ['TABLE_PREFIX'] by some individual variable of my database?
Thanks for any help!

Quote from: just_some_guy on January 09, 2008, 10:29:10 PM

<?php
$result 
cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PREFIX']}pictures");
$num_files mysql_num_rows($result);

echo 
$num_files;

?>


I suggest using anycontent.php though, as it would be easier to implement PHP.


Nibbler

Use something like this as your anycontent.php


<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2008 Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 3
  as published by the Free Software Foundation.
  
  ********************************************
  Coppermine version: 1.4.16
  $HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.4.x/anycontent.php $
  $Revision: 4233 $
  $Author: gaugau $
  $Date: 2008-02-02 09:23:58 +0100 (Sat, 02 Feb 2008) $
**********************************************/

/**
* Coppermine Photo Gallery 1.4.14 anycontent.php
*
* This file file gets included in the index.php if you set the option in admin
* can be used to display any content from any program, it is always to be edited
* according to tastes and then used
*
* @copyright 2002,2007 Gregory DEMAR, Coppermine Dev Team
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License V3
* @package Coppermine
* @version $Id: anycontent.php 4233 2008-02-02 08:23:58Z gaugau $
*/

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

$result cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']}");
list(
$numpics) = mysql_fetch_row($result);

starttable("100%""Welcome");

?>

<tr><td class="tableb" >
Welcome, there are $numpics files in the gallery.
</td></tr>
<?php
endtable
();

?>



You don't need to modify it; just copy/paste. Then add anycontent into your config (content of the main page) setting.

just_some_guy

The "Welcome,..." line will just print out $numpics instead of a number.


<?php
echo "Welcome, there are "$numpics ." files in the gallery.";
?>

Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums