/    Sign up×
Community /Pin to ProfileBookmark

adding 2 tables with a $variable name

hello coder, i have a forum, which gets information by these 2 tables.

[code=php]$tbl_name=”forum_question”;
$tbl_name=”forum_answer”;[/code]

i have changed it so it gets the data from the $users alliance name:

[code=php]
$tbl_name = $row[‘alliance_name’] . “_question”;
$tbl_name = $row[‘alliance_name’] . “_answer”;
[/code]

how can i do it on when a user creates a forum to make the two tables called

[code=php]$row[‘alliance_name’] . “_question”
$row[‘alliance_name’] . “_answer”[/code]

[QUOTE]

Table forum_question
CREATE TABLE `forum_question` (
`id` int(4) NOT NULL auto_increment,
`topic` varchar(255) NOT NULL default ”,
`detail` longtext NOT NULL,
`name` varchar(65) NOT NULL default ”,
`datetime` varchar(25) NOT NULL default ”,
`view` int(4) NOT NULL default ‘0’,
`reply` int(4) NOT NULL default ‘0’,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;

Table forum_answer
CREATE TABLE `forum_answer` (
`question_id` int(4) NOT NULL default ‘0’,
`a_id` int(4) NOT NULL default ‘0’,
`a_name` varchar(65) NOT NULL default ”,
`a_answer` longtext NOT NULL,
`a_datetime` varchar(25) NOT NULL default ”,
KEY `a_id` (`a_id`)
) TYPE=MyISAM;

[/QUOTE]

would CREATE TABLE `$row[‘alliance_name’] . “_question”` (

work??

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MrCoderFeb 27.2008 — Don't make a new table for each "alliance", instead just use a link table.

forum_answer and forum_question would be linked to your alliance table using a table called alliance_to_answers and alliance_to_questions for example.

But then again surely answers are already linked to questions, so only questions would need linking to the alliance table?
Copy linkTweet thisAlerts:
@mitchellauthorFeb 27.2008 — i dont know how to make the query to add 2 tables (above) called $row['alliance_name']+_answers and _questions

so when i create an alliance called fred it makes 2 tables called

fred_answers

fred_question
×

Success!

Help @mitchell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...