The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Averaging MySQL fields
Hi,
I'm trying to write a simple query to retrieve an average of fields in one of my tables. Code:
$average = $DB_site->query("SELECT AVG(points) FROM usrPoints WHERE atoContId = 662"); Can anyone help me set the query to actually return a value? Thanks. |
#2
|
||||
|
||||
Maybe
PHP Code:
|
#3
|
|||
|
|||
I don't need the table prefix for my database so I removed that.
But using $average['avgpoints'] does work! Thanks!!! |
#4
|
||||
|
||||
I also don't need that in my database.
But it is good coding style to follow vB3 coding standards. And it makes life easier if you ever have to switch your host(and then maybe have to use prefixes) |
#5
|
|||
|
|||
True. But if I were to ever need prefixes it would be a week long undertaking to fix the other queries in my custom pages as well.
Thanks so much for the assist Kirby. I owe you one. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|