![]() |
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. |
Maybe
PHP Code:
|
I don't need the table prefix for my database so I removed that.
But using $average['avgpoints'] does work! Thanks!!! |
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) |
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. |
All times are GMT. The time now is 01:44 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|