Welcome to Geeklog Wednesday, September 26 2018 @ 02:31 am EDT

Geeklog Forums

what'm i doing wrong?


bwaynef

Anonymous
PHP Formatted Code
function phpblock_happytimes ()
{
    $sql = "SELECT SUM(times) FROM table WHERE DATE_SUB( CURDATE( ) , INTERVAL 31 DAY ) <= date GROUP BY WEEK(date) DESC LIMIT 4";
    return DB_query($sql);
}
 


I get "Resource id #133" from the Home topic (125, 124, & 120 on other topics) in that block.

The SQL is legit and should return 2 rows of 1 field (does in phpMyAdmin). Admittedly I know little about php. Can anyone help?

Thanks

Status: offline

THEMike

Forum User
Moderator
Registered: 25/07/03
Posts: 141
Location:Sheffield, UK
DB_query either returns false, or a result set resource. It does not return any HTML or anything that can be directly evaluated to a meaningful string.

You will need to write some code to loop through all the results in that result set and format them up as HTML. Using DB_numResults (hmm not 100% sure that's the right function name) and DB_fetchArray.

bwaynef

Anonymous
You mention DB_. Where can I find out more about those functions??

Thanks for your help,

Status: offline

THEMike

Forum User
Moderator
Registered: 25/07/03
Posts: 141
Location:Sheffield, UK
lib-database.php in the system directory of your geeklog install.

bwaynef

Anonymous
Thanks.

I got it working already. I'll have to read thru that file and get this figured out. Thanks for the pointers though.


All times are EDT. The time is now 02:31 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content