adding mysql values

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

Post Reply
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

adding mysql values

Post by SidewinderX »

assume i have a database called top50 with a table called users that looks like this

Code: Select all

name     points     posts
x        10         30
y        50         13
z        100        16
How do i add all of the points of every user?
imstupid
Forum Commoner
Posts: 84
Joined: Fri Feb 18, 2005 1:24 pm

Post by imstupid »

this should get you started at least

Code: Select all

<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ; 

echo $points ;

?>
5e9de48c]
<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?&ampcode

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?&gt;
SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
ry("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
u started at least

Code: Select all

<?PHP
// connect code

$getallpoints = mysql_query(&quote;SELECT SUM(points) AS totalpoints FROM users&quote;) ;
$points = mysql_result($getallpoints, 'totalpoints', 0u started at least

Code: Select all

<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ; 

echo $points ;

?>
code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
= mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?&gt;
]
<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
ql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
least

Code: Select all

<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ; 

echo $points ;

?>
;

?>
etallpoints, 'totalpoints', 0) ;

echo $points ;

?>
]u started at least

Code: Select all

<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ; 

echo $points ;

?>
a95e9de48c]
<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0)) ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
1]
<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
ts', 0) ;

echo $points ;

?>
lt($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
ints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
ast

Code: Select all

<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ; 

echo $points ;

?>
u started at least

Code: Select all

<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ; 

echo $points ;

?>
esult($getallpoints, 'totalpoints', 0) ; 

echo $points ;

?>
;lt;?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users&quote;) ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?&gt;
[/phpp;quote;) ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?&gt;
u started at least

Code: Select all

<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ; 

echo $points ;

?>
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
alpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
u started at least

Code: Select all

<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ; 

echo $points ;

?&ampconnect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ; 

echo $points ;

?>
hp]
<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
[/php:1:a95e9de"SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
a95e9de48c]
<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
ers") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
[/php$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
CT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
mp;quote;) ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
oints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totary("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
<?PHP
// connect code

$getallpoints = mysql_query(&quote;SELECT SUM(points) AS totalpoints FROM users&quote;) ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
points = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
e;) ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?&gt;
p;lt;?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
t

Code: Select all

<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ; 

echo $points ;

?>
$points ;

?>
48c]
<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>

// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
ints', 0) ;

echo $points ;

?>

<?PHP
// connect code

$getallpoints = mysql_query("SELECT SUM(points) AS totalpoints FROM users") ;
$points = mysql_result($getallpoints, 'totalpoints', 0) ;

echo $points ;

?>
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Post by SidewinderX »

ok that worked now on to the next step.

Now lets assume i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong?ts assume i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

&lt;?php
$db = mysql_connect(&quote;localhost&quote;, &quote;&quote;, &quote;&quote;);
mysql_select_db(&quote;top50&quote;,$db);
$result = mysql_query(&quote;SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getallkills, 'totalkills', 0);

echo &quote;Kills &quote;.$kills;
echo &quote;&lt;br&gt;&quote;;

}
?&aalled 'squads' which contains the names of every other table on the database. For example the table squads has the information[quote]abc, def, hij, klm[/quote]
and all the other tables in my database are also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

&lt;?php
$db = mysql_connect(&quote;localhost&quote;, &quote;&quote;, &quote;&quote;);
mysql_select_db(&quote;top50&quote;,$db);
$result = mysql_query(&quote;SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getallkills, 'totalkills', 0);

echo &quote;Kills &quote;.$kills;
echo &quote;&lt;br&gt;&quote;;

}
?&gt;
When i run t tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", &quote;&quote;, &quote;&quote;);
mysql_select_db(&quote;top50&quote;,$db);
$result = mysql_query(&quote on to the next step.

Now lets assume i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information[quote]abc, def, hij, klm[/quote]
and all the other tables in my database are also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

&lt;?php
$db = mysql_connect(&quote;localhost&quote;, &quote;&quote;, &quote;&quote;);
mysql_select_db(&quote;top50&quote;,$db);
$result = mysql_query(&quote;SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getallkills, 'totalkills', 0);

echo &quote;Kills &quote;.$kills;
echo &quote;&lt;br&gt;&quote;;

}
?&gt;
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 differ on to the next step.

Now lets assume i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong?ow = mysql_fetch_assoc($result))
{
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it shoul0, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_queryre multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information[quote]abc, def, hij, klm[/quote]
and all the other tables in my database are also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

&lt;?php
$db = mysql_connect(&quote;localhost&quote;, &quote;&quote;, &quote;&quote;);
mysql_select_db(&quote;top50&quote;,$db);
$result = mysql_query(&quote;SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getalle i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information[quote]abc, def, hij, klm[/quote]
and all the other tables in my database are also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo &quo database. For example the table squads has the information[quote]abc, def, hij, klm[/quote]
and all the other tables in my database are also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

&lt;?php
$db = mysql_connect(&quote;localhost&quote;, &quote;&quote;, &quote;&quote;);
mysql_select_db(&quote;top50&quote;,$db);
$result = mysql_query(&quote;SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getallkills, 'totalkills', 0);

echo &quote;Kills &quote;.$kills;
echo &quote;&lt;br&gt;&quote;;

}
?&gt;
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Becaus named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_qxt step.

Now lets assume i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information[quote]abc, def, hij, klm[/quote]
and all the other tables in my database are also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong?uote]abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong?mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong?or example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getallkills, 'totalkills', 0);

echo &quote;Kills &quote;.$kills;

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
on to the next step.

Now lets assume i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getallkills, 'totalkills', 0);

echo &quote;Ki want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong?lets assume i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 differother table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong?w lets assume i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that ituads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

&lt;?php
$db = mysql_connect(&quote;localhost&quote;, "", "");
mysql_select_db("top50",$db);
$result = mysql_query(&quote;SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
ese. For example the table squads has the information[quote]abc, def, hij, klm[/quote]
and all the other tables in my database are also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

&lt;?php
$db = mysql_connect(&quote;localhost&quote;, &quote;&quote;, &quote;&quote;);
mysql_select_db(&quote;top50&quote;,$db);
$result = mysql_query(&quote;SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getallkills, 'totalkills', 0);

echo &quote;Kills &quote;.$kills;
echo &quote;&lt;br&gt;&quote;;

}
?&gt;
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100[/quote is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

&lt;?php
$db = mysql_connect(&quote;localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkilare also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($reere are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information[quote]abc, def, hij, klm[/quote]
and all the other tables in my database are also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong? step.

Now lets assume i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong? def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect(&quote;localhost&quote;, &quote;&quote;, &quote;");
mysql_select_db("top50",$db);
$result = my on to the next step.

Now lets assume i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information[quote]abc, def, hij, klm[/quote]
and all the other tables in my database are also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

&lt;?php
$db = mysql_connect(&quote;localhost&quote;, &quote;&quote;, &quote;&quote;);
mysql_select_db(&quote;top50&quote;,$db);
$result = mysql_query(&quote;SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getallkills, 'totalkills', 0);

echo &quote;Kills &quote;.$kills;
echo &quote;&lt;br&gt;&quote;;

}
?&gt;
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because tabase. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

&lt;?php
$db = mysql_connect(&quote;localhost&quote;, &quote;&quote;, &quote;&quote;);
mysql_select_db(&quote;top50&quote;,$db);
$result = mysql_query(&quote;SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getallkills, 'totalkills', 0);

echo &amdatabase called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information[quote]abc, def, hij, klm[/quote]
and all the other tables in my database are also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

&lt;?php
$db = mysql_connect(&quote;localhost&quote;, &quote;&quote;, &quote;&quote;);
mysql_select_db(&quote;top50&quote;,$db);
$result = mysql_query(&quote;SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getallkills, 'totalkills', 0);

echo &quote;Kills &quote;.$kills;
echo &quote;&lt;br&gt;&quote;;

}
?&gt;
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrongf every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong? on to the next step.

Now lets assume i have a database called top50, and in there there are multiple tables. One table called 'squads' which contains the names of every other table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be somethiner table on the database. For example the table squads has the information
abc, def, hij, klm
and all the other tables in my database are also named
abc, def, hij, klm
What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysqlh contains the names of every other table on the database. For example the table squads has the information[quote]abc, def, hij, klm[/quote]
and all the other tables in my database are also named [quote]abc, def, hij, klm[/quote]

What i want to do is use $squads to query the database...the code i have partially works but it only displays one piece of information...here is my code

Code: Select all

<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads&quote;,$db);
while($row = mysql_fetch_assoc($result))
{  
extract($row);



$getallkills = mysql_query(&quote;SELECT SUM(kills) AS totalkills FROM $squads&quote;);
$kills = mysql_result($getallkills, 'totalkills', 0);

echo &quote;Kills &quote;.$kills;
echo &quote;&lt;br&gt;&quote;;

}
?&gt;
When i run that it displays this

[q<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("top50",$db);
$result = mysql_query("SELECT * FROM squads",$db);
while($row = mysql_fetch_assoc($result))
{
extract($row);



$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");
$kills = mysql_result($getallkills, 'totalkills', 0);

echo "Kills ".$kills;
echo "<br>";

}
?>
When i run that it displays this
Kills 250
Kills
it should be something like
Kills 250
Kills 100
Because there are 2 different $squads....if that made any sense what am i doing wrong?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
    $kills = $getallkills['totalkills'];
    echo "Kills ".$kills;echo "<br>";
}
mp;quote;SELECT SUM(kills) AS totalkills FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kil FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkillsї'totalkills'];
echo &quote;Kills &quote;.$kills;echo &quote;&lt;br&gt;&quote;;
}

while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}

$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads&quote;);

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkillsї'totalkills'];
echo &quote;Kills &quote;.$kills;echo &quote;&a
$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
s FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
e;);

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo &quote;Kills &quote;.$kills;echo &quote;&lt;br&gt;&quote;;
}
;SELECT SUM(kills) AS totalkills FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
s = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
amp;quote;.$kills;echo "<br>";
}
#1111;'totalkills'];
echo "Kills ".$kills;echo "<br>";
}
p;quote;<br>";
}

$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
"SELECT SUM(kills) AS totalkills FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo &quote;Kills &quote;.$kills;echo &quote;&a
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
y("SELECT SUM(kills) AS totalkills FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
echo "Kills ".$kills;echo "<br>";
}
ills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
];quote;);

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
= mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkillsї'totalkills'];
echo &quote;Kills &quote;.$kills;echo &quote;&lt;br>";
}

$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads&quote;);

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;ecllkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
(kills) AS totalkills FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkillsї'totalkills'];
echo &quote;Kills &quote;.$kills;echo &quote;&lt;br&gt;&quote;;
}
[/phplkills)
{
$kills = $getallkills['totalkills'];
echo &quote;Kills &quote;.$kills;echo &quote;&lt;br&gt;&quote;;
}

$getallkills = mysql_query("SELECT SUM(kills) AS totalkills FROM $squads");

// loop through results
while($array = mysql_fetch_assoc($getallkills)
{
$kills = $getallkills['totalkills'];
echo "Kills ".$kills;echo "<br>";
}
Post Reply