MySQL Forums
Forum List  »  Newbie

Re: Display sum of table in one line of text?
Posted by: Claude Martin
Date: March 29, 2005 12:14AM

Matthew Jones wrote:
> Ok, I think I am understanding you now. :)
>
> So, using that query (I assume 'myclanwarz' would
> be the databse name, but what would 'team' be? a

no, its the table!its always the database then table then field but if you choose a database (mysql_select_db()) then you dont need the database and if you have only one table then you can just write the name of the field.
the full name of a field would be:
`database`.`table`.`field`

> mysql table, or just a name that doesn't exist in
> mysql, that simply identifys something later on?),
> what php code would I need to add to make it
> work?

the team would be the field where the ID of the team is stored.
you should have one table where every team has one row and there you have some fields like this:

CREATE TABLE `teams` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 30 ) NOT NULL ,
`description` VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( `id` )
);

so ID is primary key. this also means that its unique.

> Would I start by querying it (
> $result=my_sql_query(blah,blah) ? - not sure if

not really.
<?
$result = mysql_query("SELECT * FROM table");
$row = mysql_fetch_asoc($result);
echo $row["team"];
?>

> that is right, without checking), then do a fetch
> array, then call it up with an echo thing?

yes echo is good. maybe you want to use htmlentities because there yould bo some characters that need to be htmlencoded.

> Could this all be done in a block that can be
> added to the bottom of the page, or do I need to
> put parts in certain places?

thats up to you. you can make a funtion that returns the skill score or even a class that you can use anywhere.
you should use files that you include. e.g. a file db.php that has all stuff to connect to the datanase and then you only need to include this:

include_once("db.php");

note: the path is relative to the file that was requested by the user!
so you might want to use this:

include_once ($_SERVER["DOCUMENT_ROOT"]."/path/db.php");

http://animalliberation.tk http://veganismus.ch
http://maqi.de http://tierrechtskochbuch.de

Options: ReplyQuote


Subject
Written By
Posted
Re: Display sum of table in one line of text?
March 29, 2005 12:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.