Hey guys, you were so helpful with my last issue (which I'm very greatful for) I'm back to share another growing pain, and the last for now at least.
my row is looking like this:
network | user_amt | war_one | war_two | war_three | war_four | war_five
sample ----- 50 ------- 70 -------- 5 --------- 8 -------- 3 -------- 9
the war_one - five fields are just counters for the users selections but I need to calculate the highest value from the last five war fields (e.g 70) and divide it by the total value of the war fields (e.g 95) then times by 100 to return a percentage along with the highest fields name.
I have similar set ups in the database where the same returns are needed but their universal and can be column calculated where as this table is network specific so proving to be a bit difficult (for my learner level php)
Any help would be as always greatly appreciated ,
Jason
Row calculation problem
Moderator: General Moderators
Re: Row calculation problem
Your database structure will make this a total nightmare to do in SQL. Fetch the data from the database and do the calculation in PHP. Better yet, redesign the database to hold the score values in a better way (eg 1 per row).
Re: Row calculation problem
~onion2k is right - you should redesign your database. Give each row 3 columns - `network`, `user`, and `war`. It'll then be much easier to do complex queries.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.