| Author |
Message |
wicked
Joined: Oct 27, 2004
Posts: 11
Status: Offline
|
  Posted:
May 24, 2005 - 01:55 AM |
|
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  |
|
|
|
 |
Chestnut
Site Admin
Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
|
  Posted:
May 24, 2005 - 07:03 AM |
|
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 !
Administrator
PNConcept.com
Last edited by Chestnut on May 24, 2005 - 07:04 AM; edited 1 time in total |
|
 |
 |
|
|
| |