Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

php and tables
Hi

I am new to php and mysql and am having a few problems that I hope someone c
an help with.

What I am trying to do is to display ratings for particular teams using some
 basic code. I needed to print the information out on a table with the highe
st average at the top and then ascending. I have all this info stored in a m
ysql db.
eg
TEAM        PLAYED  WIN   LOSS   DRAW  POINTS   AVERAGE
ENGLAND     16           6         6          4          16              1.0
0

I don't know how to print variables out in a table and I don't know how to m
ake it ascending.

Any help would be much appreciated.

Thanks

Vikas

Send instant messages to your online friends http://uk.messenger.yahoo.com

Report this thread to moderator Post Follow-up to this message
Old Post
Vikas Nanda
04-17-05 08:55 PM


Re: php and tables
There are two places you can figure out the average: in MySQL or in
PHP.  Then  you want to sort the results by this Average: in MySql use
"ORDER BY" and  in php use "array_multisort"

in  MySQL your SQL might look like:

SELECT   TEAM, PLAYED, WIN, LOSS, DRAW, POINTS, POINTS / PLAYED as
AVERAGE
FROM <your  table>
ORDER BY AVERAGE desc

in PHP you'd  have to loop through your results loading  them into a
local array with  an additional column for average and then use
array_multisort which has many options (and  I don't exactly remember
how to make  it  work exactly but look at:
<http://www.phpbuilder.com/manual/fu...y-multisort.php> to
see).

I'd do it in  MySQL  but that's me...

Good luck,
Frank

On Apr 17, 2005, at 2:13 PM, php-db-digest-help@lists.php.net wrote:

> From: Vikas Nanda <vikasnandauk@yahoo.co.uk>
> Date: April 17, 2005 7:39:57 AM PDT
> To: php-db@lists.php.net
> Subject: php and tables
>
>
> Hi
>
> I am new to php and mysql and am having a few problems that I hope
> someone can help with.
>
> What I am trying to do is to display ratings for particular teams
> using some basic code. I needed to print the information out on a
> table with the highest average at the top and then ascending. I have
> all this info stored in a mysql db.
> eg
>  TEAM        PLAYED  WIN   LOSS   DRAW  POINTS   AVERAGE
> ENGLAND     16           6         6          4          16
>   1.00
>
> I don't know how to print variables out in a table and I don't know
> how to make it ascending.
>
> Any help would be much appreciated.
>
> Thanks
>
> Vikas


Report this thread to moderator Post Follow-up to this message
Old Post
Frank M Flynn
04-19-05 01:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP DB archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:14 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.