bwaynef

Anonymous
Text 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: 07/25/03
Posts: 141
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: 07/25/03
Posts: 141
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.