21
javier
Re: help with mysql query in latest downloads block
  • 2004/3/30 14:46

  • javier

  • Not too shy to talk

  • Posts: 184

  • Since: 2002/8/6 1


mysql debug:

SELECT lid, cid, title, date, hits FROM xoops_mydownloads_downloads WHERE cid IN () ORDER BY date DESC LIMIT 0, 10
Error number: 1064
Error message: You have an error in your SQL syntax near ') ORDER BY date DESC LIMIT 0, 10' at line 1

code:
include_once (XOOPS_ROOT_PATH."/class/xoopstree.php");
$xt = new XoopsTree('xoops_mydownloads_cat'"cid""pid");
$categories $xt->getAllChildId(9);
$categorystring "(";
foreach (
$categories as $key => $categoryid) {
    if (
$key != 0) { //Only comma-separate subsequent categories
        
$categorystring .= ", ";
    }
    
$categorystring .= $categoryid;
}
$categorystring implode(','$categories);
$result $xoopsDB->query("SELECT lid, cid, title, date, hits FROM xoops_mydownloads_downloads WHERE cid IN ($categorystring) ORDER BY {$options[0]} DESC"$options[1], 0);

22
Mithrandir
Re: help with mysql query in latest downloads block

either use the foreach loop or Dave's suggestion - however, I've just noticed that his solution doesn't take the top category into consideration.

So go with this:
$sel_category 9;
include_once (
XOOPS_ROOT_PATH."/class/xoopstree.php");
$xt = new XoopsTree('xoops_mydownloads_cat'"cid""pid");
$categories $xt->getAllChildId($sel_category);
$categorystring implode(','$categories);
$categorystring $sel_category.",".$categories;
$result = [...]

23
javier
Re: help with mysql query in latest downloads block
  • 2004/3/30 16:07

  • javier

  • Not too shy to talk

  • Posts: 184

  • Since: 2002/8/6 1


i get 2 errors

mysql debug block1

SELECT lid, cid, title, date, hits FROM xoops_mydownloads_downloads WHERE cid IN (9,Array) ORDER BY date DESC LIMIT 0, 10
Error number: 1054
Error message: Unknown column 'Array' in 'where clause'

mysql debug block2

SELECT lid, cid, title, date, hits FROM xoops_mydownloads_downloads WHERE cid IN (9,Array) ORDER BY date DESC LIMIT 0, 10
Error number: 1054
Error message: Unknown column 'Array' in 'where clause'

No matter what number i put in $sel_category= in block2,
it always take the number of the other file (9)

code:
$sel_category 9;
include_once (
XOOPS_ROOT_PATH."/class/xoopstree.php");
$xt = new XoopsTree('xoops_mydownloads_cat'"cid""pid");
$categories $xt->getAllChildId($sel_category);
$categorystring implode(','$categories);
$categorystring $sel_category.",".$categories;
$result $xoopsDB->query("SELECT lid, cid, title, date, hits FROM xoops_mydownloads_downloads WHERE cid IN ($categorystring) ORDER BY {$options[0]} DESC"$options[1], 0);

24
Mithrandir
Re: help with mysql query in latest downloads block

bleh... it should of course be
$categorystring = $sel_category.",".$categorystring;

Is the block2 exactly the same apart from $sel_category = 9 ?

25
javier
Re: help with mysql query in latest downloads block
  • 2004/4/1 11:05

  • javier

  • Not too shy to talk

  • Posts: 184

  • Since: 2002/8/6 1


now all works fine :) :)

i was made only the latest files blocks, now i added the top files ones and update the module.
the problem dissapear.

Thanks ALOT for your help Mithrandir i will not forget about,

grettings

26
Mithrandir
Re: help with mysql query in latest downloads block

You are so very welcome

Login

Who's Online

147 user(s) are online (95 user(s) are browsing Support Forums)


Members: 0


Guests: 147


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits