Author Topic: How do you add total image hits to the main index page  (Read 5449 times)

0 Members and 1 Guest are viewing this topic.

Offline cam101

  • Pre-Newbie
  • Posts: 9
    • View Profile
How do you add total image hits to the main index page
« on: September 18, 2006, 09:28:16 PM »
Hi there, was just wondering if anyone knows how to add the total images hit number that is displayed in the control panel, on the main index page, i am typing it in manualy at the moment but its getting tedious and i am sure there must be a way.
« Last Edit: September 18, 2006, 09:38:50 PM by cam101 »

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: How do you add total image hits to the main index page
« Reply #1 on: September 18, 2006, 09:59:14 PM »
1. All Images
... add this in your index.php ...
Code: [Select]
//-----------------------------------------------------
// --- All total images -----
//-----------------------------------------------------
  $sql = "SELECT COUNT(*) AS all_total_images
          FROM ".IMAGES_TABLE."
          WHERE image_active = 1";
  $row = $site_db->query_firstrow($sql);
  $all_total_images = $row['all_total_images'];
  $site_template->register_vars("all_total_images", $all_total_images);
  unset($all_total_images);
//-----------------------------------------------------

... then you can use this in your home.html ...

Code: [Select]
All images : {all_total_images}

2. All Image Hits
... add this in your index.php ...
Code: [Select]
//-----------------------------------------------------
// --- All Image Hits -----
//-----------------------------------------------------
  $sql = "SELECT SUM(image_hits) AS sum
          FROM ".IMAGES_TABLE;
  $row = $site_db->query_firstrow($sql);
  $total_image_hits = $row['sum'];
  $site_template->register_vars("total_image_hits", $total_image_hits);
  unset($total_image_hits);
//-----------------------------------------------------

... then you can use this in your home.html ...

Code: [Select]
All image hits : {total_image_hits}
« Last Edit: September 19, 2006, 04:25:27 AM by mawenzi »
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline cam101

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: How do you add total image hits to the main index page
« Reply #2 on: September 18, 2006, 10:13:48 PM »
sorry for the quick reply. I was actually looking to display the total number of "image hits" within the site, as displayed in the Administration panel rather than the actual Total images contained within the site.

I'm sure its just a case of altering variables, but as i've only recently started using the package i'm still unsure. Your help is appreciated, thanks.
« Last Edit: September 18, 2006, 10:23:56 PM by cam101 »

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: How do you add total image hits to the main index page
« Reply #3 on: September 19, 2006, 12:38:22 AM »
... sorry , I was too fast ...  :oops: ...
... I updated my post above ...
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline cam101

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: How do you add total image hits to the main index page
« Reply #4 on: September 19, 2006, 01:00:44 AM »
Thanks for your quick reply and the code you have posted works but there is an error, not sure how to post this but in the first line i had to change it to get it to work. You had put   $sql = "SELECT SUM(total_image_hits) AS sum and i had to change it to this to get it to work $sql = "SELECT SUM(image_hits) AS sum  

Only writing this in case anyone else views this topic.
Thanks for your help, Problem solved.   :D

Offline HorrorCrafT

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • HYPOfun online
Re: How do you add total image hits to the main index page
« Reply #5 on: September 19, 2006, 10:23:43 AM »
mawenzi, sag mal schläfst du auch mal? :mrgreen:

with "$sql = "SELECT SUM(image_hits) AS sum" it works perfect! thx!

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: How do you add total image hits to the main index page
« Reply #6 on: September 19, 2006, 12:30:16 PM »
@ HorrorCrafT
... danke der berechtigten Nachfrage ...
... dafür bin ich demnächst für 'ne Weile verschwunden ...  :mrgreen:
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...