vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Basic PHP questions from newbie, help me finish this up (https://vborg.vbsupport.ru/showthread.php?t=40912)

Jungleman 07-10-2002 10:12 PM

Basic PHP questions from newbie, help me finish this up
 
OK, I'm not sure if it's already been done but I'm making something which shows the person with the most posts per day at the top of the forum...

First of all, I've added a new column to the "user" table which has posts per day of each user, and it sticks the user's posts per day in that field and that is the value that shows up on the home page...I am using the following query to generate those numbers:

Code:

UPDATE user SET ppd=posts/((UNIX_TIMESTAMP(NOW())-joindate)/86400)
Only problem is I don't want to keep manually running that query, how can I make it so it runs that query whenever someone loads index.php?

Secondly, I need to round the number to the nearest 100th. How can I do that?

Thanks...

Jungleman 07-11-2002 02:24 AM

Ah come on, nobody knows?

Xenon 07-11-2002 07:46 AM

you have to add something like that in your index.php:

$DB_site->query("UPDATE user SET ppd=posts/((UNIX_TIMESTAMP(NOW())-joindate)/86400)");

basically i wouldn't do that into index.php, because it is run so often.
put it into memberlist.php, i think there you show up the users sorted by ppd right?

second: sorry i don't understand what you want, can you explain it a bit more? (sorry, perhaps its my english ;))

Jungleman 07-11-2002 10:14 AM

Thanks...:)

OK, I have a numerical value that I'm pulling from my database and I want to round it to the nearest 100th, like if the value is 29.468384 I want to make it show 29.47.

Thanks :)

Xenon 07-11-2002 11:13 AM

i see if you want to round the variable:

$ppd=round($ppd*100)/100;

if you just want to show it with two digits use this:
$ppd = sprintf("%.2f",$ppd);

as located in member.php ;)

Jungleman 07-11-2002 11:49 AM

Thanks, figured that out shortly after I posted though ;)

Xenon 07-11-2002 11:54 AM

:)

np


All times are GMT. The time now is 12:32 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00955 seconds
  • Memory Usage 1,716KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete