PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Sun Jul 18, 2004 7:35 pm
Code: Select all
echo $data["calwins"];
echo (" - ");
echo $data["calloss"];
echo (" - ");
echo $data["caltie"];
echo ("<br><br><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b>U</b>nited <b>G</b>aming <b>S</b>yndicate (UGS):");
echo $data["ugswins"];
echo (" - ");
echo $data["ugsloss"];
echo (" - ");
echo $data["ugstie"];
echo ("<br><br><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">Overall:");
echo $data["overallwins"];
echo (" - ");
echo $data["overallloss"];
echo (" - ");
echo $data["overalltie"];
how do i get cal<fill in> and ugs<fill in> to add up to overall<fill in>?
whats the code?
-- also --
whats the code so it only list's 1 set of numbers, not even win/loss/tie submitted (ex: right now i have
Code: Select all
while ($data = mysql_fetch_assoc($result)) {)
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Mon Jul 19, 2004 9:31 am
Maybe share a little more on what you're trying to do and what you need help with
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Mon Jul 19, 2004 3:47 pm
pickle wrote:
Maybe share a little more on what you're trying to do and what you need help with
its for clan, i want the CAL score and UGS Score to add together to get the Overall Score
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Mon Jul 19, 2004 3:56 pm
pretty simple I think:
Code: Select all
$overall_score =($calwins - $calloss) + ($usgwins - $usgloss)
Last edited by
pickle on Mon Jul 19, 2004 4:04 pm, edited 1 time in total.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Jul 19, 2004 4:01 pm
maybe something like this?
Code: Select all
<?php
$prefixes = array('cal','ugs');
$parts = array('wins','loss','tie');
foreach($parts as $part)
{
if(isset($data[$prefixes[0].$part]) && isset($data[$prefixes[1].$part])
$data['overall'.$part] = (int)$data[$prefixes[0].$part] + (int)$data[$prefixes[1].$part];
}
?>
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Mon Jul 19, 2004 6:56 pm
pickle wrote: pretty simple I think:
Code: Select all
$overall_score =($calwins - $calloss) + ($usgwins - $usgloss)
not really what i ment.. but u gave me an idea
Code: Select all
$overall_wins = ($calwins + $ugswins)
$overall_loss = ($calloss + $ugsloss)
$overall_tie = ($caltie + ugstie)
that would work successfully wouldnt it?
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Tue Jul 20, 2004 9:20 am
Yep.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Tue Jul 20, 2004 5:47 pm
whats the code so it doesnt echo every line in the mySQL table?
(what i have right now:
Code: Select all
while ($data = mysql_fetch_assoc($result)) { echo $data["calwins"];)
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Tue Jul 20, 2004 6:12 pm
can you rephrase your question a bit better?
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Tue Jul 20, 2004 6:47 pm
Code: Select all
$data = mysql_fetch_assoc($result))
keeps making each data with in a table echo out to a page..
example: echo $data["test"];
each item that lies under "test" feild is outputted.. i just want 1 output
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Jul 20, 2004 6:48 pm
you should structure your query such that it returns the row(s) you want then.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Tue Jul 20, 2004 7:53 pm
feyd wrote: you should structure your query such that it returns the row(s) you want then.
something like
Code: Select all
<?php
mysql_query("SELECT * FROM `records` LIMIT 1");
?>
or
Code: Select all
<?php
mysql_query("SELECT * FROM `records` WHERE id='".$_GET["id"]."'");
?>
which will find a certain record depending on which var is in the url
ie. index.php?id=5