Jump to content

how to create and store in multiple database?


Recommended Posts

how to create and store in multiple database?

 

eg..when detect the user's input is  male then store into a male's database

while if  female then store into a female's database

 

how to write a control of store different type of group into different db?

thanks..

Create a variable for a database and check it in if..else condition

 

if ($male) 
{
$sLocalDatabaseName = "male_db";
} 
else 
{
$sLocalDatabaseName = "female_db";
}

 

and after that you need to define your connection

$conn = mysql_connect($sLocalHost,$sLocalUser,$sLocalPassword);
$db=mysql_select_db($sLocalDatabaseName);

 

 

By the way, you can do this using 2 tables. No need of multiple DB.

n~ link=topic=167981.msg740495#msg740495 date=1195227370]

Create a variable for a database and check it in if..else condition

 

if ($male) 
{
$sLocalDatabaseName = "male_db";
} 
else 
{
$sLocalDatabaseName = "female_db";
}

 

and after that you need to define your connection

$conn = mysql_connect($sLocalHost,$sLocalUser,$sLocalPassword);
$db=mysql_select_db($sLocalDatabaseName);

 

 

By the way, you can do this using 2 tables. No need of multiple DB.

 

then how to switch between two or more tables?

 

n~ link=topic=167981.msg741358#msg741358 date=1195376146]

Are you really using more that 1 database. It will be a headache later... Same thing can be achieved through 1 database with two tables for male and female.

You're talking about vertical partitioning... that's an advanced technique.

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.