TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

June 26, 2024, 01:02:24 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,280
  • Total Topics: 21,227
  • Online today: 203
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 187
  • Total: 187

SMF Downloads block?

Started by Heero, March 09, 2008, 02:45:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Heero

Hmm yeah thanks dude!
You just fixed this up in two days :)

Although, I'd like to ask one little thing for it:
Could you fix the code,
so the block will only show the file(s) of a specific category?
Thanks in advance!

~- Heero

Dragooon

No problem, I love to help others and I love coding.
Use the fol. code
global $db_prefix, $scripturl;
$cats = array(1,2,3);
$request = db_query("SELECT f.ID_FILE, f.ID_MEMBER, f.date, f.ID_CAT, f.title AS ftitle, f.totaldownloads,
c.title, m.realName, m.ID_MEMBER AS mID_MEMBER
FROM {$db_prefix}down_file AS f, {$db_prefix}down_cat AS c, {$db_prefix}members AS m
WHERE f.ID_CAT = c.ID_CAT
AND f.approved = '1'
AND f.ID_MEMBER = m.ID_MEMBER
".!empty($cats) ? "AND f.ID_CAT IN('".implode(',',$cats)."')" : ''."
ORDER BY f.ID_FILE DESC
LIMIT 5",__FILE__,__LINE__);
while($row = mysql_fetch_assoc($request)) {
echo '<table width="100%" cellpadding="2" cellspacing="0">
<tr>
<td valign="top" class="smalltext"> <a href="',$scripturl,'?action=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a></td>
<td valign="top" class="smalltext" align="right">',$row['totaldownloads'],'</td>
</tr>
</table>';
}


$cats is a array, containing IDs of cats to show from
If I wrote it right, it should show from every cat if left empty.

Heero

Seems like it casts an error :D

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 f.ID_CAT IN('1,2,3')' at line 1
File: /home/xxx/domains/domain.org/public_html/smf/Sources/Load.php(1770) : eval()'d code(209) : eval()'d code
Line: 11

And thanks again for your reply.
I really appreciate what you're doing here :)

Dragooon

Hmm
Try this one
global $db_prefix, $scripturl;
$cats = array(1,2,3);
$request = db_query("SELECT f.ID_FILE, f.ID_MEMBER, f.date, f.ID_CAT, f.title AS ftitle, f.totaldownloads,
c.title, m.realName, m.ID_MEMBER AS mID_MEMBER
FROM {$db_prefix}down_file AS f, {$db_prefix}down_cat AS c, {$db_prefix}members AS m
WHERE f.ID_CAT = c.ID_CAT
AND f.approved = '1'
AND f.ID_MEMBER = m.ID_MEMBER
".!empty($cats) ? "AND f.ID_CAT IN(".implode(',',$cats).")" : ''."
ORDER BY f.ID_FILE DESC
LIMIT 5",__FILE__,__LINE__);
while($row = mysql_fetch_assoc($request)) {
echo '<table width="100%" cellpadding="2" cellspacing="0">
<tr>
<td valign="top" class="smalltext"> <a href="',$scripturl,'?action=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a></td>
<td valign="top" class="smalltext" align="right">',$row['totaldownloads'],'</td>
</tr>
</table>';
}

I think it was those damn single quotes causing trouble.

If it works, make sure you enter valid Category IDs

Heero

Damn sorry .. :/
It still doesn't works.
It returns the following error :

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 f.ID_CAT IN(1)' at line 1
File: /home/xxx/domains/domain.org/public_html/smf/Sources/Load.php(1770) : eval()'d code(209) : eval()'d code
Line: 11

damns,
Thanks again.

fussilet

#25
I corrected the council...

code :
Quote<a href="',$scripturl,'?action=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a>

I exchanged

Quote<a href="',$scripturl,'?action=downloads;sa=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a>

Dragooon

Can't seem to figure out what Is wrong, I'll see to it later :)

fussilet

Now, There isn't the problem  ;)

Dragooon

I wasn't talking about that, I was talking about showing from specific categories.
And can you remove the [color=red BBC tags since in Code block the other BBC doesn't works.

Heero

Well fussilet check what Dragooon said,
The code works, but showing specific categories fails somehow and returns an error O.o!