Jump to content

Recommended Posts

can anyone help me i have a mysql database for the code

<?php function gloss($word, $team)

{

   $sql = "SELECT `team{$team}` FROM glossary WHERE word='{$word}'";

   return ret11($sql);

}
echo gloss("title", $teamid) .', Welcome to your <B>' .gloss("barracks",$teamid) . '</B>!'; ?>

 

but they way i've made the table in the database it's not working. I think this is more sql help but i can provide the table i have made if it helps? can someone help me out with the layout or point me in the right direction?

[/code]

EDIT

DATaBASE CODE

 

--
-- Table structure for table `glossary`
--

CREATE TABLE IF NOT EXISTS `glossary` (
  `title` text NOT NULL,
  `barracks` text NOT NULL,
  `word` text NOT NULL,
  `team` int(11) NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

 

Link to comment
https://forums.phpfreaks.com/topic/192264-database-structure/
Share on other sites

You are using some custom functions to do your database activities: ret11() and gloss(). So, there is no way for us to know what the problem really is. I doubt this has anything to do with your database structure.

 

The only thing I can *guess* from the code  you have provided is that it looks like you are only querying for the "team" field, but you are trying to use results for "title" and "barracks". In fact, the variable $team in the query makes no sense. It is being concatenated to the field name "team" and you have no fields in the database with team and additional characters.

Link to comment
https://forums.phpfreaks.com/topic/192264-database-structure/#findComment-1013192
Share on other sites

You do not have the column team{$team} in your database design. Not sure what you want, perhaps an AND statement?

 

$sql = "SELECT `team` FROM glossary WHERE word='{$word}' AND team = '{$team}'";

 

Given that you have the or die mysql_error, you should have been given an error that the column team$team does not exist (whatever $team is).

Link to comment
https://forums.phpfreaks.com/topic/192264-database-structure/#findComment-1013329
Share on other sites

No, this is what your function needs to look like:

 

function gloss($word, $team) {
   $sql = "SELECT `{$word}` FROM glossary WHERE team='{$team}'";
   return ret11($sql);
}

Although I must say everytime you call that function you are basically running a query. You could just run one at the top of the page and use the results to show all the columns.

Link to comment
https://forums.phpfreaks.com/topic/192264-database-structure/#findComment-1013331
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.