Reply to Re: Help with COUNT() on a php form

Your name:

Reply:


Posted by J.O. Aho on 01/10/06 17:46

bigsamurai wrote:
> Good day... I have included the code of a form that i am trying to get
> to work. The object of the form will be to show a person the number of
> flight hours they have and the number of flights that they have
> accomplished. However I am getting an error saying that the result can
> not be found. PLZ HELP as I am pullingm y hair out and do not have
> much left to begin with.!!!

> /* Get pilots info */
> for ($i=0; $i<$number; $i++) {
> $miss_tot = mysql_result($result,$i,"(COUNT(miss_no))");
> $hours_tot =
> mysql_result($result,$i,"(SUM(miss_hours))");

I think you have misunderstood how mysql_result() works, it's used to get a
column from your result from the mysql_query().

You have the following columns that you can use:

mission.miss_pilot_assign,
pilot.pilot_no, pilot.pilot_name,
mission.miss_status,
mission.miss_no,
mission.miss_hours

$miss_tot = mysql_result($result,$i,"mission.miss_no");
$hours_tot = mysql_result($result,$i,"mission.miss_hours");

Of course this will not be the total amount of hours per pilot or how many
missions they have done, it's just the result from that line in the joined table.

You would need to make an additional query to get those two:

$query = "SELECT COUNT(mission.miss_no),
SUM(mission.miss_hours)
FROM mission, pilot
WHERE
mission.miss_pilot_assign=pilot.pilot_no
AND
mission.miss_status=3
AND
pilot.pilot_name='$_POST[pilot_name]'
GROUP
by mission.miss_status";



//Aho

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация