Page 2 of 2
Posted: Wed Mar 31, 2004 5:46 pm
by tim
post the code your now using
seems you didnt define the variables, you need this script:
$h = $row['hSum'];
$ab = $row['abSum'];
Posted: Wed Mar 31, 2004 5:51 pm
by warriors2003
<?php
$h = $row['hSum']; // ills code
$ab = $row['abSum'];
//this can be anywhere on the page after the mysql_fetch_array cause the fetch_array helps point the row grabbing
// the code you have:
echo "<tr bgcolor=\"$color\"><td><b>$row[avgAvg]</b></td><td><b>$row[hSum]</b></td><td><b>$row[abSum]</b></td><td><b>$row[hrSum]</b></td><td><b>$row[rbiSum]</b></td><td><b>$row[rSum]</b></td><td><b>$row[doublesSum]</b></td><td><b>$row[triplesSum]</b></td><td><b>$row[sbSum]</b></td>"; // ends your echo, but not your table
echo "<td><b>$h/$ab; </b></td></tr>"; // the new echo that incorperates in your table with ills variable.
?>
Thanks again for trying to help!!
Posted: Wed Mar 31, 2004 6:50 pm
by warriors2003
When it displays the data,,,it has 2/13
It shows the total hits with the division sign then the total at bats,,but it isn;t actually doing the math and then displaying it for output,,,I think we are really close tho!!!
Posted: Wed Mar 31, 2004 6:56 pm
by warriors2003
HOLY GEESE!!! I GOT IT!! Don;t know how i pulled it off,,,prolly with alot of luck!!!
I added this to the bottom of Ill's code
$row[avg] = $row['hSum']/$row['abSum'];
<?php
$h = $row['hSum']; // ills code
$ab = $row['abSum'];
$row[avg] = $row['hSum']/$row['abSum'];
Then just used a regular echo with a row being [avg]
THAT SEEMED TO DO IT!!! Thanks guys!!!
Posted: Wed Mar 31, 2004 7:32 pm
by tim
well congrats
i'm happy that not only the problem is corrected, but I was wrong and you was right
Excellent job
Posted: Wed Mar 31, 2004 7:41 pm
by warriors2003
You guys were right all along!!! I wouldn;t have been able to get it anywhere close to figure out if it wasnt for you guys!!!
But one quick question....I remember you helped me with the rounding function in the sql yesterday, but since the parameters have now changed in the code, i've been palying around with it and can't get it to round,,,again..lol.
This is what you gave me yesterday
"SELECT SUM(h) as hSum, round(avg(Avg), 3) as avgAvg blah blah
And that worked!!!
But now the paramter has changed to just "avg" and its not in the database somethign I can select, its a total i put math work too,,,,,,it might have to be moved to be rounded somwhere else in the code,,,,cause I tried changing the above code a million different ways to fit avg, can't get it to round!!!
Any thoughts??
Posted: Wed Mar 31, 2004 8:06 pm
by tim
well look at the other thread, you'll get it.
hint: you wont use the sql version provided by wierdan =]
also, php.net is your bible.
http://www.php.net/manual/en/function.round.php
Posted: Wed Mar 31, 2004 8:33 pm
by warriors2003
Mission accomplished Jedi Master....
Posted: Wed Mar 31, 2004 9:42 pm
by Illusionist
you dont ahve to use $row['avg'] to assign that to, you can jsut assing it to $avg.