Forum Index   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
wickedOffline



Joined: Oct 27, 2004
Posts: 11

Status: Offline
Post   Posted: May 24, 2005 - 01:55 AM Reply with quote Back to top

I try to create a block that shows the top news submitters on the last [period time] and it doesn't show anything :S

This is the sql that i execute...

Code:
$newDayRaw = (time()-(86400 * 7));
$newDB = Date("Y-m-d", $newDayRaw);

$sql  = "SELECT $userscolumn[uid], $userscolumn[uname], $userscolumn[counter], $newscolumn[time] FROM $userstable, $newstable AND $newscolumn[time] LIKE '%$newDB%'";


Where 7 is the number of days.

Thanks for your support Smile
View user's profile Send private message
Chestnut
Site Admin


Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
Post   Posted: May 24, 2005 - 07:03 AM Reply with quote Back to top

I'm not expert of this sort of things but from what I see... you are asking in your sql what news is LIKE 7days before and ... think I see another error. You are missing a where...

Think something like this would be more appropriate :

Code:

$newDayRaw = (time()-(86400 * 7));
$newDB     = date("Y-m-d H:i:s", $newDayRaw);

$sql  = "SELECT $userscolumn[uid],
                $userscolumn[uname],
                $userscolumn[counter],
                $newscolumn[time]
                count(*) as ncount,
         FROM   $userstable,
                $newstable
         WHERE  $usercolumn[uname] = $newscolumn[informant]
         AND    $newscolumn[time] >= '".pnVarPrepForStore($newDB)."'";


This is to tell the sql that you want the news where the username is like the news informant
Code:

WHERE  $usercolumn[uname] = $newscolumn[informant]




And this is to get all what happened since 7 days ago
Code:

AND    $newscolumn[time] >= '".pnVarPrepForStore($newDB)."'";


The number of news for each user will be given in the "ncount" later in your code.

Code:

list($uid, $uname, $newscounter, $newstime, $ncount) = $result->fields;


Try this and see if it works...

_________________
Chestnut ! Cool
Administrator
PNConcept.com


Last edited by Chestnut on May 24, 2005 - 07:04 AM; edited 1 time in total
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits
DarkMindZ