Author Topic: Help me with code please...  (Read 19273 times)

0 Members and 1 Guest are viewing this topic.

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
Re: Help me with code please...
« Reply #15 on: September 27, 2010, 01:35:13 AM »
Oh, now I understand :)
In that case scratch my previous post ;) $user_id - is what you need.

You can simplify your code with with:

$sql "SELECT SUM(image_hits) AS sum 
        FROM "
.IMAGES_TABLE."
        WHERE user_id = 
$user_id";
$result $site_db->query_firstrow($sql);
$tot_hits $lang['total_hits']." <B>".($result['sum'] ? $result['sum'] : 0)."</B>\n";
$site_template->register_vars("tot_hits"$tot_hits);
unset(
$tot_hits);
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 MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: Help me with code please...
« Reply #16 on: October 23, 2010, 06:51:13 PM »
I have this code. Work fine! But...

$most_viewed_name .= "";  
$most_viewed_name .= time() - 60 60 24 7;        
        
$sql "SELECT i.image_name as name, SUM(i.image_hits) AS hit_sum
        FROM "
.IMAGES_TABLE." i
        WHERE i.image_date >= "
.$most_viewed_name."
        GROUP BY name ORDER BY hit_sum DESC
        LIMIT 5"
;


$result $site_db->query($sql);

$sum = (isset($row['hit_sum'])) ? $row['hit_sum'] : 0;
   
   while (
$row $site_db->fetch_array($result)) {
$most_viewed_name .= "<tr>";
$most_viewed_name .= "<td align=\"left\">";
$most_viewed_name .= '<a href ="'.ROOT_PATH.'/search.htm?search_fields=image_name&search_keywords='.$row['name'].'" title="'.$row['hit_sum'].' views today"><b>'.$row['name'].'</b></a>';
$most_viewed_name .= "</td>";
$most_viewed_name .= "</tr>";
}

$site_template->register_vars(array(
"most_viewed_name" => $most_viewed_name,
));
unset(
$most_viewed_name);




What is the number and how to delete it??? (Yellow mark)

Rembrandt

  • Guest
Re: Help me with code please...
« Reply #17 on: October 23, 2010, 07:11:00 PM »
$most_viewed_name .= "";  
$timetime() - 60 60 24 7;        
        
$sql "SELECT i.image_name as name, SUM(i.image_hits) AS hit_sum
        FROM "
.IMAGES_TABLE." i
        WHERE i.image_date >= "
.$time."
        GROUP BY name ORDER BY hit_sum DESC
        LIMIT 5"
;

.
.
.


mfg Andi

Offline MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: Help me with code please...
« Reply #18 on: October 23, 2010, 08:08:15 PM »
Fine! Thanks!  :D