Author Topic: how to show top downloads on index page  (Read 8229 times)

0 Members and 1 Guest are viewing this topic.

Offline yousaf

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
how to show top downloads on index page
« on: October 21, 2007, 01:09:11 PM »
i am not good in php, plz move this post to its proper section if it is not right here.

i tried to used the top downloaded images code {lang_top_image_rating} {image_rating_1} n others on home.html

and added the below code of top downloads to index.php from top.php

Quote
// Downloads
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_downloads,

c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id
        $cat_match_sql
        ORDER BY i.image_downloads DESC, i.image_name ASC
        LIMIT 10";
$result = $site_db->query($sql);
$top_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result)) {
  $top_list[$i] = $row;
  $i++;
}
$site_db->free_result();

for ($i = 1; $i <= 10; $i++) {
  if (isset($top_list[$i])) {
    $register_array['image_downloads_'.$i] = (check_permission("auth_viewimage",

$top_list[$i]['cat_id'])) ? "<a

href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."

\">".format_text($top_list[$i]['image_name'])."</a>" :

format_text($top_list[$i]['image_name']);
    $register_array['image_downloads_openwindow_'.$i] = (check_permission("auth_viewimage",

$top_list[$i]['cat_id'])) ? "<a

href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."

\" onclick=\"opendetailwindow()\"

target=\"detailwindow\">".format_text($top_list[$i]['image_name'])."</a>" :

format_text($top_list[$i]['image_name']);
    if (isset($top_list[$i][$user_table_fields['user_name']]) && $top_list[$i]['user_id'] !=

GUEST) {
      $user_profile_link = (!empty($url_show_profile)) ? preg_replace("/{user_id}/",

$top_list[$i]['user_id'], $url_show_profile) :

ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$top_list[$i]['user_id'];
      $register_array['image_downloads_user_'.$i] = "<a

href=\"".$site_sess->url($user_profile_link)."\">".format_text($top_list[$i][$user_table_fields

['user_name']])."</a>";
    }
    else {
      $register_array['image_downloads_user_'.$i] = $lang['userlevel_guest'];
    }
    $register_array['image_downloads_cat_'.$i] = "<a

href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\

">".format_text($top_list[$i]['cat_name'])."</a>";
    $register_array['image_downloads_number_'.$i] =

"<b>".$top_list[$i]['image_downloads']."</b>";
  }
  else {
    $register_array['image_downloads_'.$i] = "--";
    $register_array['image_downloads_user_'.$i] = "--";
    $register_array['image_downloads_cat_'.$i] = "--";
    $register_array['image_downloads_number_'.$i] = "--";
  }
}

$site_template->register_vars($register_array);


//-----------------------------------------------------

but i am getting this error.

Quote
DB Error: Bad SQL Query: SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_downloads, c.cat_name, u.user_name FROM (4images_images i, 4images_categories c) LEFT JOIN 4images_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND i.cat_id NOT IN () AND i.cat_id = c.cat_id ORDER BY i.image_downloads DESC, i.image_name ASC LIMIT 10
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND i.cat_id = c.cat_id ORDER BY i.image_downloads DESC, i.' at line 4

how to remove this error
help needed plz anyone

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: how to show top downloads on index page
« Reply #1 on: October 21, 2007, 01:11:37 PM »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline yousaf

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: how to show top downloads on index page
« Reply #2 on: October 21, 2007, 01:28:33 PM »
the one you mentioned is really a nice Mod for statistics but i want to show something like this as i re-arranged it on top.php

i hope from this snapshot you will get what i am trying to ask :D


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: how to show top downloads on index page
« Reply #3 on: October 21, 2007, 02:25:41 PM »
Oh ok so is easy.

Find:

Quote
// Downloads

Add before:

Code: [Select]
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");

And use this fix:

http://www.4homepages.de/forum/index.php?topic=19138.0
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline yousaf

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: how to show top downloads on index page
« Reply #4 on: October 22, 2007, 03:53:15 AM »
it is working now after putting that line above the //downloads code :D thanks thunderstrike for your kind reply but need a little more help.

i thought i will put that line above the other 3 codes and they will start working too, but they aren't
can you please help me now with the other options, [  // Hits  -   // Votes   and  //ratings  ] the code line you gave only works for //downloads


ahhhhh its ok i think it was a cache problem.

« Last Edit: October 22, 2007, 07:23:52 AM by yousaf »

Offline yousaf

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: how to show top downloads on index page
« Reply #5 on: January 07, 2008, 07:53:45 AM »
thunderstrike,
is there any way how to show "new 10 images" & "new or popular 10 categories/sub categories" added in same style as top 10 downloads and votes

Offline yousaf

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: how to show top downloads on index page
« Reply #6 on: January 09, 2008, 07:14:18 AM »
help !
anyone please

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: how to show top downloads on index page
« Reply #7 on: January 09, 2008, 01:55:47 PM »
Quote
is there any way how to show "new 10 images" & "new or popular 10 categories/sub categories" added in same style as top 10 downloads and votes

Is like 3 request in 1 text ... I no get ... is possible for show e.g ?  :|
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline yousaf

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: how to show top downloads on index page
« Reply #8 on: January 10, 2008, 11:40:35 AM »
ok let me explain it a bit more

i want to show "Latest 10 NEW images" and "Latest 10 New Categories/sub catergories" added to my gallery's Index page

just like previously with your help i added "Top 10 images by votes" and "Top 10 images by downloads" to my gallery's Index page