Page 1 of 1
[UNsolved] mySQL query code
Posted: Sun Jul 18, 2004 7:35 pm
by bla5e
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)) {
)
Posted: Mon Jul 19, 2004 9:31 am
by pickle
Maybe share a little more on what you're trying to do and what you need help with

Posted: Mon Jul 19, 2004 3:47 pm
by bla5e
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
Posted: Mon Jul 19, 2004 3:56 pm
by pickle
pretty simple I think:
Code: Select all
$overall_score =($calwins - $calloss) + ($usgwins - $usgloss)
Posted: Mon Jul 19, 2004 4:01 pm
by feyd
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];
}
?>
Posted: Mon Jul 19, 2004 6:56 pm
by bla5e
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?
Posted: Tue Jul 20, 2004 9:20 am
by pickle
Yep.
Posted: Tue Jul 20, 2004 5:47 pm
by bla5e
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"];
)
Posted: Tue Jul 20, 2004 6:12 pm
by John Cartwright
can you rephrase your question a bit better?
Posted: Tue Jul 20, 2004 6:47 pm
by bla5e
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
Posted: Tue Jul 20, 2004 6:48 pm
by feyd
you should structure your query such that it returns the row(s) you want then.
Posted: Tue Jul 20, 2004 7:53 pm
by John Cartwright
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