Author Topic: total images count on homepage?  (Read 7787 times)

0 Members and 1 Guest are viewing this topic.

Offline Jasondavis

  • Full Member
  • ***
  • Posts: 157
    • View Profile
total images count on homepage?
« on: February 23, 2003, 11:19:19 AM »
Hi I had posted a while ago on this.  I would like to display the total number of images in my gallery on my home page. V@no had given me this code a while ago:


<?php

define('ROOT_PATH', './gallery/');// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie'

include(ROOT_PATH.'config.php');

include(ROOT_PATH.'includes/db_mysql.php');

include(ROOT_PATH.'includes/constants.php');

$site_db = new Db($db_host, $db_user, $db_password, $db_name);

$sql = "SELECT COUNT(*) as total_images

        FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b

        WHERE a.image_active=1

        AND a.cat_id = b.cat_id

        AND b.auth_viewcat=".AUTH_ALL."

        AND b.auth_viewimage=".AUTH_ALL."

        ";

$row = $site_db->query_firstrow($sql);

$total_images = $row['total_images'];

echo $total_images;

?>


The problem is that when I run this it displays "0" instead of "287" 287 is how many images I have, but it displays 0....Does anybody have any ideas why?

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
total images count on homepage?
« Reply #1 on: February 23, 2003, 11:55:31 AM »
something like that were discussed here http://www.4homepages.de/forum/viewtopic.php?t=3637

Offline Jasondavis

  • Full Member
  • ***
  • Posts: 157
    • View Profile
help
« Reply #2 on: February 23, 2003, 06:34:37 PM »
Hi, thanks I've seen that post, is there any way to strip it down to just display the total numberof images in my gallery all I need it the actually number like:

287

thats all I need...thanks if you can help

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
total images count on homepage?
« Reply #3 on: February 23, 2003, 08:58:37 PM »
try this one
Code: [Select]
<?php
define
&#40;'ROOT_PATH', './4images/'&#41;;
include_once&#40;ROOT_PATH.'config.php'&#41;;
include_once&#40;ROOT_PATH.'includes/db_mysql.php'&#41;;

define&#40;'PIC_CATEGORIES_TABLE', '4images_categories'&#41;;
define&#40;'PIC_IMAGES_TABLE', '4images_images'&#41;;
define&#40;'AUTH_ALL', 0&#41;;

$pics_db = new Db&#40;$db_host, $db_user, $db_password, $db_name&#41;;

$sql "SELECT COUNT&#40;*&#41; as total_images FROM ".PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b WHERE a.image_active=1 AND a.cat_id = b.cat_id AND b.auth_viewcat=".AUTH_ALL." AND b.auth_viewimage=".AUTH_ALL."";
$row $pics_db->query_firstrow&#40;$sql&#41;;
$total_images $row['total_images'&#93;;

echo "Total <b>$total_images</b> images in gallery\n";
?>

Offline Jasondavis

  • Full Member
  • ***
  • Posts: 157
    • View Profile
total images count on homepage?
« Reply #4 on: February 24, 2003, 04:11:58 AM »
Weird, it says

Total 0 images in gallery

what could it be do you think?
Right now in my gallery you have to be a member to view the pics, do you think that would have anything to do with it?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
total images count on homepage?
« Reply #5 on: February 24, 2003, 04:21:10 AM »
Quote from: Jasondavis
Weird, it says

Total 0 images in gallery

what could it be do you think?
Right now in my gallery you have to be a member to view the pics, do you think that would have anything to do with it?

it wont count images in the category that can not be accessed by guest, but if guest can visit the category, where only members can see the pictures, then this script should count them.
did u do any changes in the script, any mods, integrations?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Jasondavis

  • Full Member
  • ***
  • Posts: 157
    • View Profile
total images count on homepage?
« Reply #6 on: February 24, 2003, 04:27:30 AM »
Quote from: V@no
Quote from: Jasondavis
Weird, it says

Total 0 images in gallery

what could it be do you think?
Right now in my gallery you have to be a member to view the pics, do you think that would have anything to do with it?

it wont count images in the category that can not be accessed by guest, but if guest can visit the category, where only members can see the pictures, then this script should count them.
did u do any changes in the script, any mods, integrations?



Hey, visitors can access the categories, what did you mean by modifications....to the 4images scripts or to this script that should show the # of images?  I have done a lot of mods to the gallery, but I only changed the path to my gallery in this script.  Befor I changed the path it showed the mysql errors, then I changed it to gallery and it displays the Total 0 images thing

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
total images count on homepage?
« Reply #7 on: February 24, 2003, 04:31:13 AM »
ok, lets try one more time  :wink:
Code: [Select]
<?php
define
&#40;'ROOT_PATH', './4images/'&#41;;
include_once&#40;ROOT_PATH.'config.php'&#41;;
include_once&#40;ROOT_PATH.'includes/db_mysql.php'&#41;;

define&#40;'PIC_CATEGORIES_TABLE', '4images_categories'&#41;;
define&#40;'PIC_IMAGES_TABLE', '4images_images'&#41;;

$pics_db = new Db&#40;$db_host, $db_user, $db_password, $db_name&#41;;

$sql "SELECT COUNT&#40;*&#41; as total_images FROM ".PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b WHERE a.image_active=1 AND a.cat_id = b.cat_id";
$row $pics_db->query_firstrow&#40;$sql&#41;;
$total_images $row['total_images'&#93;;

echo "Total <b>$total_images</b> images in gallery\n";
?>

this script doesnt have restriction on user level. it should show total images as if u were logged in as admin.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Jasondavis

  • Full Member
  • ***
  • Posts: 157
    • View Profile
works
« Reply #8 on: February 24, 2003, 04:32:52 AM »
wow thank you, I have been trying this for over a month that one works thanks a lot i appreciate it!

Offline ashfaq

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Re: total images count on homepage?
« Reply #9 on: September 09, 2007, 05:12:13 PM »
Where to put this code to show total images of my site ?