February 04 2012 16:15:27
Languages
Navigation
Friends & Affiliates
Roadmap
[N] Error log like in P...
[N] Submit photo - Subc...
[N] Warnings - who can ...
[N] [edit profile]Save ...
[N] Moving panels with ...
[N] Forum thread deform...
[N] Thumbnails in downl...
[N] [Locale German] New...
[N] Warnings only for a...
[N] Different avatar sizes
Users Online
· Guests Online: 7

· Members Online: 0

· Total Members: 464
· Newest Member: Erikutis
Last Seen Users
· dalem21:08:08
· Erikutis23:15:45
· videry 1 day
· inflames 1 day
· SilverAngel 2 days
· jebajseti 2 days
· outchorn 2 days
· uygarozan 4 days
· deejay-erik 5 days
· DJSimse 5 days

Login
 Username  Password  
View Thread: New Panel/Infusion
Who is here? 1 Guest
 Print Thread
New Panel/Infusion
Grimloch
Hey guys.I'm working on a new infusion that will be compatible with PiF as well as regular 7.01 ... If anyone can help me I sure would appreciate it. I've run into a problem that I cannot seem to solve. No one at Mods-Net seems to be able (or willing I'm not sure which), to help out and I thought I'd try here. It should be simple and I thought it was but here is my problem:

I need to extract from the database, the usernames that logged on the PREVIOUS day using the 'user_lastvisit' field. Here is a code snippet where the problem lies:

Download source  Code
<?php

$yesterday = date("m-d-Y", mktime(0, 0, 0, date("m"), date("d")-1, date("Y")));
$visited = $yesterday;
$result = dbquery("SELECT user_id, user_name, DATE_FORMAT(user_lastvisit, '$visited') AS my_day FROM ".DB_USERS." WHERE user_lastvisit = '$my_day' AND user_status='0' ORDER BY user_lastvisit DESC");

echo "[";
$i = 0;
if (dbrows($result) != 0) {
   while ($data = dbarray($result)) {
      $i++;
      echo "<a href='".BASEDIR."profile.php?lookup=".$data['user_id']."' title='".$data['user_name']."'>".$data['user_name']."</a>";
      if ($i < dbrows($result)) { echo "] ["; }
   else { echo ""; }
   }
}
echo "]<br /><br />";
echo $visited;
?>




When I preview this in a custom page it displays 88 names from my userbase when in fact I know (at least today), that it should display 3 names as there were 3 logins yesterday. Time/Date conversions have always driven me crazy trying to figure out! I know the problem must be in the way I'm telling MySql to read the data but I just cannot figure it out. I've tried many many different configurations here and none seem to work right.

PS: The echo $visited; at the bottom DOES display yesterdays date correctly i.e.
06-22-2010
Edited by Grimloch on 23-06-2010 22:35
SignatureEnergy can neither be created nor destroyed; only transformed.
 
http://www.whisperwillow.com
Grimloch
keddy wrote:
I'll try to solve your problem tomorrow morning. Like you said... should be something simple but... isn't.


Hey keddy. I appreciate your attempt here but I think I have finally solved it and it WAS very simple actually. I did a LOT of online research and finally found the answer on a phpBB board. This is the final result which DOES work and displays users who logged on yesterday(last 24hrs):

Download source  Code
<?php

$result = dbquery("SELECT user_id, user_name, user_lastvisit FROM ".DB_USERS." WHERE user_lastvisit >= (UNIX_TIMESTAMP(CURDATE()) -86400)  AND user_status = '0' ORDER BY user_lastvisit DESC");
echo "[";
$i = 0;
if (dbrows($result) != 0) {
   while ($data = dbarray($result)) {
      $i++;
      echo "<a href='".BASEDIR."profile.php?lookup=".$data['user_id']."' title='".$data['user_name']."'>".$data['user_name']."</a>";
      if ($i < dbrows($result)) { echo "] ["; }
   else { echo ""; }
   }
}
echo "]\n";

?>




Turns out there is no need for esoteric/manipulative date/time conversions as the (UNIX_TIMESTAMP(CURDATE()) -86400) function does it all. You simply subtracting 86400 seconds from the 'user_lastvisit' field which is from midnight of the previous day to midnight lastnight. If you preview this in a custom page you'll see that it works correctly.

Thanks again for volunteering to help. I can now finish my center panel.

:D
Edited by Grimloch on 24-06-2010 15:54
SignatureEnergy can neither be created nor destroyed; only transformed.
 
http://www.whisperwillow.com
Dallas
Nice work Grim
 
http://dtawebdesigns.com/
Grimloch
Dallas wrote:
Nice work Grim


Thanks; but actually after several days of observation, the above code doesn't quite work right. The following code however does work:

Download source  Code
$result = dbquery("SELECT user_id, user_name, user_lastvisit FROM ".DB_USERS." WHERE user_lastvisit > (UNIX_TIMESTAMP(CURDATE()) -86400) AND user_lastvisit < (UNIX_TIMESTAMP(CURDATE())) AND user_status = '0' ORDER BY user_lastvisit DESC");
echo "[";
$i = 0;
if (dbrows($result) != 0) {
   while ($data = dbarray($result)) {
      $i++;
      echo "<a href='".BASEDIR."profile.php?lookup=".$data['user_id']."' title='".$data['user_name']."'>".$data['user_name']."</a>";
      if ($i < dbrows($result)) { echo "] ["; }
   else { echo ""; }
   }
}




I needed to be able to specify a range. Supposedly there is a MySql command called BETWEEN but I could find no reference or examples to it and figured out my own method of range specification.

Cheers ! :D
SignatureEnergy can neither be created nor destroyed; only transformed.
 
http://www.whisperwillow.com
Advertising Bot
Posted on 04-02-2012 16:15
Bot Agent

Posts: n^x
Joined: Always

  
slaughter
Only btw:
If your infusion is for PHP-F 7.01.xx and/or PiF, you can use the profile_link() function for the link to the user's profile.
 
Grimloch
OK. It's done! New panel mod posted under Modifications forum.

Cool
SignatureEnergy can neither be created nor destroyed; only transformed.
 
http://www.whisperwillow.com
Jump to Forum:
Similar Threads
Thread Forum Replies Last Post
bbcode permissions infusion General Questions 2 12-08-2011 15:06
Radio Panel General Questions 3 10-08-2011 23:09
Eigene Infusion entwickel Infusionen 25 31-07-2011 21:08
Pro Download Panel -> Fehler: "Strict Standards..." Infusionen 10 19-04-2011 12:11
Panel für Admin unsichtbar? Administration in Pimped-Fusion 6 22-03-2011 17:57
Share this thread
URL:
BB-Code:
HTML:
AddThis:
Share |
Render time: 0.15 seconds - 96 Queries 831,104 unique visits