Welcome to Geeklog, Anonymous Tuesday, December 10 2024 @ 07:24 pm EST
Geeklog Forums
what'm i doing wrong?
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
3
6
Quote
Status: offline
THEMike
Forum User
Moderator
Registered: 07/25/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.
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.
3
4
Quote
bwaynef
Anonymous
You mention DB_. Where can I find out more about those functions??
Thanks for your help,
Thanks for your help,
4
3
Quote
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.
I got it working already. I'll have to read thru that file and get this figured out. Thanks for the pointers though.
5
4
Quote
All times are EST. The time is now 07:24 pm.
- 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