Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com > PHP sql Mathematical problem to php

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 08-10-2007, 08:02 PM PM User | #1 2y2d New Coder   Join Date: Aug 2007 Posts: 37 Thanks: 0 Thanked 0 Times in 0 Posts sql Mathematical problem to php ok this is just me thinking and the attributes arent those of what i have but just for clarification on how i would do it ok theres 3 ranks all 3 ranks give an average score this average score is then ordered by lowest first giving an overall rank (avg rounded to nearest 10), like : 5*2*3 / 3 = 10 = 1 4*5*2 / 3 = 11 = 2 I can get this to diplay as a table but all i want is the overall rank to be displayed and also is it possible that two averages might be the same when each rank cant be the same if so would they be classed as the same overall rank?. Hope this is explained well lol im horrible at explaining things
 08-10-2007, 09:56 PM PM User | #2 mcjwb Regular Coder   Join Date: Jul 2007 Location: UK Posts: 223 Thanks: 0 Thanked 14 Times in 14 Posts First of all the average is the sum of the values divided by the number of values, not the multiplication as you have done. i.e.: 5+2+3/3 = 3.3 Second, you mention sql in the title of your post but you don't mention it anywhere else, should you have? I would imagine it is possible to get two averages the same, and yes you would class them as the same overall rank. Any chance of some code, it often helps an explanation!
 08-10-2007, 10:21 PM PM User | #3 2y2d New Coder   Join Date: Aug 2007 Posts: 37 Thanks: 0 Thanked 0 Times in 0 Posts i havent started to code it yet, the sql part i can do its just putting it together to form the php , but what i was wondering was how to make the sql so that 2 overall ranks arent the same like say two people had an average of 10 how would i get to display as this = player 1 avg = 10 rank 1 player 2 avg = 10 rank 2 i think im just confusing myself further lol but i hope you understand.
 08-10-2007, 10:24 PM PM User | #4 mcjwb Regular Coder   Join Date: Jul 2007 Location: UK Posts: 223 Thanks: 0 Thanked 14 Times in 14 Posts Can you post the sql you have, then I can have something to go on?
 08-10-2007, 10:45 PM PM User | #5 2y2d New Coder   Join Date: Aug 2007 Posts: 37 Thanks: 0 Thanked 0 Times in 0 Posts Code: `SELECT `CARank`+`SARank`+`DARank`/3 = `Orank`FROM `MainT` Order by `Orank` Desc` it displays = `CARank` + `SARank` + `DARank` / 3 = `Orank` 1 1 1 But its not showing just one overall rank and if another user has the same i want them to both have seperate ranks.
 08-10-2007, 10:52 PM PM User | #6 mcjwb Regular Coder   Join Date: Jul 2007 Location: UK Posts: 223 Thanks: 0 Thanked 14 Times in 14 Posts Sorry, but I think I need to see the table definition to answer that.
 08-10-2007, 11:01 PM PM User | #7 2y2d New Coder   Join Date: Aug 2007 Posts: 37 Thanks: 0 Thanked 0 Times in 0 Posts ok its no problem ill wait till i have something coded in php thanks for the help though i appreciate it i just think i need to understand it more lol
 08-10-2007, 11:07 PM PM User | #8 Inigoesdr Super Moderator     Join Date: Mar 2007 Location: Florida, USA Posts: 3,628 Thanks: 2 Thanked 404 Times in 396 Posts Code: `SELECT (`CARank` + `SARank` + `DARank`) / 3 AS `Orank`, `username` FROM `MainT` ORDER BY `Orank` DESC` Will give you the average for the row, and if you use the result number as the rank they will all have separate ranks. ie. PHP Code: ``` \$result = mysql_query('SELECT (`CARank`  + `SARank` + `DARank`) / 3  AS `Orank`, `username` FROM `MainT` ORDER BY `Orank` DESC');\$count = 1;while(\$row = mysql_fetch_assoc(\$result)){    print \$count . ' - ' . \$row['username'] . '';    \$count++;}  ``` Last edited by Inigoesdr; 08-10-2007 at 11:10 PM..
 08-10-2007, 11:19 PM PM User | #9 2y2d New Coder   Join Date: Aug 2007 Posts: 37 Thanks: 0 Thanked 0 Times in 0 Posts Thank you thats excactly what i was looking for all i have to do is add 2 more fields. see i have three users all with the same stats (just for testing) but they do all come out as different ranks thanks.
 08-11-2007, 12:10 AM PM User | #10 mcjwb Regular Coder   Join Date: Jul 2007 Location: UK Posts: 223 Thanks: 0 Thanked 14 Times in 14 Posts Ah I understand now, sorry I think I was looking for something more complicated!
 08-11-2007, 12:40 AM PM User | #11 2y2d New Coder   Join Date: Aug 2007 Posts: 37 Thanks: 0 Thanked 0 Times in 0 Posts lol sorry , i think i thought there was something more complicated about it as well lol But thanks

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 09:24 AM.