4images Forum & Community
The forum for all 4images gallery administrators
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
[2023-01-23] 4images 1.10 released
Home
Help
Search
Login
Register
4images Forum & Community
»
General / Allgemeines
»
Programming
»
Help me with code please...
« previous
next »
Print
Pages:
1
[
2
]
Author
Topic: Help me with code please... (Read 21087 times)
0 Members and 1 Guest are viewing this topic.
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...
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
);
Logged
Your first three "must do" before you ask a question:
Forum rules
FAQ
Error messages
Bug Fixes & Patches
Search
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)
MrAndrew
Sr. Member
Posts: 302
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)
Logged
Rembrandt
Guest
Re: Help me with code please...
«
Reply #17 on:
October 23, 2010, 07:11:00 PM »
$most_viewed_name
.=
""
;
$time
=
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 >= "
.
$time
.
"
GROUP BY name ORDER BY hit_sum DESC
LIMIT 5"
;
.
.
.
mfg Andi
Logged
MrAndrew
Sr. Member
Posts: 302
Re: Help me with code please...
«
Reply #18 on:
October 23, 2010, 08:08:15 PM »
Fine! Thanks!
Logged
Print
Pages:
1
[
2
]
« previous
next »
4images Forum & Community
»
General / Allgemeines
»
Programming
»
Help me with code please...