to previous topic Print topic to next topic

 Root :: Developments :: Blocks :: Top News submitters
 Moderated by:
 
  Bottom  Top News submitters
wicked Posted: 24.05.2005, 02:55
Noob
Noob


registered: Oct 27, 2004
Posts: 11

Status:  offline
last visit: 27.07.05
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
  1. $newDayRaw = (time()-(86400 * 7));
  2. $newDB = Date("Y-m-d", $newDayRaw);
  3.  
  4. $sql  = "SELECT $userscolumn[uid], $userscolumn[uname], $userscolumn[counter], $newscolumn[time] FROM $userstable, $newstable AND $newscolumn[time] LIKE '%$newDB%'";
  5.  


Where 7 is the number of days.

Thanks for your support :)
Top  wicked send PM
 
Chestnut Posted: 24.05.2005, 08:03
Site Admin
avatar

registered: Jun 02, 2002
Posts: 1320

Status:  offline
last visit: 07.02.08
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
  1. $newDayRaw = (time()-(86400 * 7));
  2. $newDB     = date("Y-m-d H:i:s", $newDayRaw);
  3.  
  4. $sql  = "SELECT $userscolumn[uid],
  5.                 $userscolumn[uname],
  6.                 $userscolumn[counter],
  7.                 $newscolumn[time]
  8.                 count(*) as ncount,
  9.          FROM   $userstable,
  10.                 $newstable
  11.          WHERE  $usercolumn[uname] = $newscolumn[informant]
  12.          AND    $newscolumn[time] >= '".pnVarPrepForStore($newDB)."'";
  13.  


This is to tell the sql that you want the news where the username is like the news informant
Code
  1. WHERE  $usercolumn[uname] = $newscolumn[informant]
  2.  




And this is to get all what happened since 7 days ago
Code
  1. AND    $newscolumn[time] >= '".pnVarPrepForStore($newDB)."'";
  2.  


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

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


Try this and see if it works...

Chestnut ! Cool
Site Admin
Top  Chestnut send PM Homepage
 



Powered by pnForum Version 2.0.1
DarkMindZ