CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 voting product - average value in grid (php)

Print topic Send  topic

Author Message
Tomasz
Posted: 10/05/2002, 10:46 AM

I have grid with top 5 popular films (an oppinion can be given to each film, with grade 1-10).
All oppinions are stored in separate table 'rewiev'. I want to display average grade for each of 5 top films, I've tried to use the following:

$db->query("SELECT AVG(r_grade) FROM review WHERE r_f_id=". $fldf_id);

table 'rewiev' is simple:
r_id (pkey)
r_f_id (id of graded product)
r_grade (grade value)

'f_id' is from table 'film' which is a source for my grid.

Such query doesn't work, becouse my grid display more than 1 record and $fldf_id contain all values..

Can anybody guide me to solution? (php+templates)
Nicole
Posted: 10/07/2002, 7:30 AM

Tomasz,
Execute the query in the form Before Show event (CC) or form Before Show Row event (CCS) I also suggest you to use dlookup() (for CC)/CCDlokUp() (for CCS) function, otherwise you should open new db connection to execute custom query and preserve the query id of generated query.
So the code could be:
CC:
$val = dlookup("review", "AVG(r_grade)", "r_f_id = ". $fldf_id);
CCS:
global $form_name;
global $DB<connection_name>;
$val = CCDlookUp("AVG(r_grade)", "review", "r_f_id=". $form_name->f_id->Value, $DB<connection_name>);
Tomasz
Posted: 10/08/2002, 6:15 AM

thank you very much, Nicole

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.