|
| Author |
Message |
Eavaan
Joined: 24 Feb 2004
Posts: 2
|
Posted: 2/26/2004, 6:02 pm Post subject: A PHP newb question... |
|
|
I am trying to get data out of a MySql database so I can perform a mathamtical operation on it and have the original data and the result displayed. Im using the following querry and it works great for getting and displaying the original data but it thows a fit when I try to do any math to it.
| Code: |
$query ="Select teamname, wins, losses FROM teams";
$result= mysql_query($query) or die ("j00 focked up");
|
What I want to do, is have "losses" divided by "wins" so yield the win percentage. Normally I don't post questions this "noobish" but this is really driving me nuts and Im not sure what topics to search under to find a good answer or example. Hopefully somebody here can help me.
Thanks! [/code] |
|
| Back to top |
|
 |
Burning_Cyclope
Joined: 26 Feb 2004
Posts: 61
Location: MA
|
Posted: 2/26/2004, 8:49 pm Post subject: |
|
|
show us the entire code.
I think the problem is that you have to create different variables in each one, rather than out the actual mathematical operation; which PHP doesn't seem to like. _________________ www.extremestuff.net
www.extremestuff.net/forum
Do yourself a favor and click the above links. |
|
| Back to top |
|
 |
Joël0
Joined: 08 Mar 2004
Posts: 6
Location: 't Stad
|
Posted: 4/6/2004, 12:32 am Post subject: |
|
|
I dont know if this is what you want...long time ago since the last post to ;o
| Code: |
<?php
// first conect to database?
mysql_connect ("localhost","username", "password");
mysql_select_db("database");
$query = "SELECT teamname, wins, losses FROM teams";
$result = mysql_query($query) or die ("<b>Error!</b> Cant conect to database...");
$obj = mysql_fetch_object($result);
// lets echo the results...
echo "Team: $obj->team <br /> Wins: $obj->wins <br /> Losses: $obj->losses"; }
?>
|
_________________ PhpDesigners |
|
| Back to top |
|
 |
|