Jump to content


Photo

getting the product from 2 arrays.


  • Please log in to reply
2 replies to this topic

#1 idos

idos
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 22 August 2006 - 04:26 PM

I'm making a script where i want to multiply  from 2 columns in a mySQL database and sum the product.

1 User submit values in a form  (grade and accent style(in climbing)) (they see a string but the values are  int.)
2 Theese values are stored in a db
3 i use a quiery to display them in a table but now and the numbers are converted to strings from an array.
4 i multiply the grade and the accentstyle integers and get the individual score the route produced..


so far so good

5 i now want to sum the individual route score to a scoretotal for each person, but so far i haven't managed to both multiply the  2 columns and sum them.  i have tried to create a multidimentional array and use array_product($multidimarray)  but with no luck so far...

can some one please help... 




[attachment deleted by admin]

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 22 August 2006 - 04:46 PM

Either of these two should work for you:

$grad = array($row['Grad']);
$bestigning = array($row['Bestigning']);

$score = $grad[0] * $bestigning[0];
echo $score;

$score = array($row['Grad'], $row['Bestigning']);
echo(array_product($score));


#3 idos

idos
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 24 August 2006 - 04:51 PM

Hmm well i still can't get it to work.

But i have  altered the form and insert.php to insert  the score in the database.

I can get the  total score in MyPHPadmin  using this quiery:

[code=php:0]$sql = 'SELECT SUM(score) FROM `ruter` WHERE Navn = \'"username"\' ORDER BY `Grad` LIMIT 0,20';


So my question is: How can i display the SUM(score) result from the database...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users