DeveloperCube - A PHP newb question...
Community management insight at ManagingCommunities.com
Username:    Password:
Remember Me?    
A PHP newb question...

 
Post new topic   Reply to topic    DeveloperCube Forum Index -> Scripts and Programming
 See a User Guidelines violation? Please contact us.
Author Message

Eavaan

Joined: 24 Feb 2004
Posts: 2

PostPosted: 2/26/2004, 6:02 pm    Post subject: A PHP newb question... Reply with quote

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

PostPosted: 2/26/2004, 8:49 pm    Post subject: Reply with quote

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

PostPosted: 4/6/2004, 12:32 am    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    DeveloperCube Forum Index -> Scripts and Programming All times are GMT
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Links: Programming Forum - Art Schools Online

Network: iFroggy Network Blog - iFroggy Hosting - SportsForums.net - KarateForums.com - YanksBlog.com - phpBBHacks.com - PhotoshopForums.com - Managing Online Forums - ManagingCommunities.com - CommunityAdmins.com - DrGregHouse.com - Bad Boy Blog - SodaRatings.com - Patrick O'Keefe

We Support phpBBHacks.com. Forum Icons by Daz. Privacy Policy. Powered by phpBB © phpBB Group. phpBB SEO.
Copyright © 2003-2009. DeveloperCube, iFroggy Network. All Rights Reserved.

Advertising   Contact   Links   Link To Us   Staff   User Guidelines