473,386 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to return the average of one field of a recordset

I have a php file which allows users to select up to 11 different selects to narrow down which parts/products best meet their requirements.

The php returns a table listing all products which meet their requirements as indicated by the selects that they have chosen.

I have a 12th field that is not shown in the table. That field as "photo values". The average of the "photo values" determines which photo is shown along with the table.

The code for my select is:

Expand|Select|Wrap|Line Numbers
  1. mysql_select_db($database_swagesert, $swagesert);
  2. $query_rsswagesert = sprintf("SELECT PartNo, IntThd, ExtThd, Lgth, MSNumber, Matl, DecID, DecOD, Pitch, Lok, Finish, Photo FROM swagesert WHERE PartNo LIKE %s AND short LIKE %s AND IntThd LIKE %s AND ExtThd LIKE %s AND Lgth LIKE %s AND Matl LIKE %s AND DecID LIKE %s AND DecOD LIKE %s AND Pitch LIKE %s AND Lok LIKE %s AND Finish LIKE %s" , 
  3. GetSQLValueString($colname1_rsswagesert, "text"),
  4. GetSQLValueString($colname2_rsswagesert, "text"),
  5. GetSQLValueString($colname3_rsswagesert, "text"),
  6. GetSQLValueString($colname4_rsswagesert, "text"),
  7. GetSQLValueString($colname5_rsswagesert, "text"),
  8. GetSQLValueString($colname6_rsswagesert, "text"),
  9. GetSQLValueString($colname7_rsswagesert, "text"),
  10. GetSQLValueString($colname8_rsswagesert, "text"),
  11. GetSQLValueString($colname9_rsswagesert, "text"),
  12. GetSQLValueString($colname10_rsswagesert, "text"),
  13. GetSQLValueString($colname11_rsswagesert, "text"),
  14. GetSQLValueString($colname12_rsswagesert, "text"));
  15. $rsswagesert = mysql_query($query_rsswagesert, $swagesert) or die(mysql_error());
  16. $row_rsswagesert = mysql_fetch_assoc($rsswagesert);
  17. $totalRows_rsswagesert = mysql_num_rows($rsswagesert);
  18.  
And the select gets called with:

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. do { ?>
  3. <tr class="chart">
  4. <td><?php echo $row_rsswagesert['PartNo']; ?></td>
  5. <td><?php echo $row_rsswagesert['MSNumber']; ?></td>
  6. <td><?php echo $row_rsswagesert['IntThd']; ?></td>
  7. <td><?php echo $row_rsswagesert['ExtThd']; ?></td>
  8. <td><?php echo $row_rsswagesert['Lgth']; ?></td>
  9. <td><?php echo $row_rsswagesert['Matl']; ?></td>
  10. <td><?php echo $row_rsswagesert['DecID']; ?></td>
  11. <td><?php echo $row_rsswagesert['DecOD']; ?></td>
  12. <td><?php echo $row_rsswagesert['Pitch']; ?></td>
  13. <td><?php echo $row_rsswagesert['Lok']; ?></td>
  14. <td><?php echo $row_rsswagesert['Finish']; ?></td>
  15. </tr> 
  16. <?php
  17.        } while ($row_rsswagesert = mysql_fetch_array($rsswagesert)); ?>
  18. </table> 
  19.  
How can I get the average of the 'Photo' field to return so the photovalue can be determined?
Sep 28 '10 #1
0 1121

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Alan Silver | last post by:
Hello, I have an ASP that takes a connection string and SQL statement in the querystring and is supposed to return the XML representation of the recordset to the Response stream (don't worry,...
1
by: Richard | last post by:
I need to dynamically add (but not remove) vectors of doubles based on keys/names. Please see my code below. Am I reinventing the wheel or doing anything inefficiently? I get the feeling that I am,...
5
by: Randy Harris | last post by:
How can I report an average of non zero values? If the values are: 5, 0, 6, 0, 4 I would like the result 5 (15 / 3), not 3 (15 / 5) Thanks for any help...
2
by: John Dalberg | last post by:
Hi What's the regex to remove the carriage return/line field from a string? These can occur multiple times in the string as in xxx\r\n\r\n. -- John Dalberg
0
by: EG | last post by:
Hi have anyone seen this error before ? i try to use VC.NET2003 to create a ATL COM ,returning a traditional ADO recordset. but i'm unable to compile. its keeps on getting MIDL error error...
6
by: James | last post by:
I am writing a web service for a classic ASP application. I need to consume an ADO recordset and then send it to another web service for processing. I found an MSDN ariticle telling how to do this...
1
by: rover | last post by:
Hi We have an application that runs fine on SQL 2000. Due to other applications we are forced to move to SQL 2005. One Stored Procedure isn't working on the new SQL 2005. It's a SP with output...
5
by: jl2886 | last post by:
I have four fields in my table that I want to average providing the fields have a value, not the null, for each case(id). I also have an average field in my table. I have a form for the table and I...
1
by: Grex | last post by:
I have a table with about 20 fields. There is a name field that is populated repeatedly with the same names over and over. Let's say 1000 records, and 25 names. Each name is in there 40 times. I...
2
by: jac130 | last post by:
I have an array, populated with student grades. there is a list of student names, but their grades are stored in a class level array. there is a calculate average button,that is supposed to calculate...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.