Jump to content

Recommended Posts

Hi,

I've created an application which stores its data in a MySQL Database, and it has a section to do with Checkboxes, but at the moment every checkbox is stored in a different database so I have 20 odd different databases. I know I can combine them with something like a example_example thing, but the problem is I've got no idea what the thing is called!

 

The config file is

 

<?php
$user="username"; //username of the MySQL database
$password="password"; //password of the MySQL database
$database="monday1"; //database you want to open in the MySQL database
$host="localhost"; //host to connect to for the MySQL database
?>

 

Is it as simple as changing the database name so it looks like;

 

<?php
$user="username"; //username of the MySQL database
$password="password"; //password of the MySQL database
$database="bb_monday1"; //database you want to open in the MySQL database
$host="localhost"; //host to connect to for the MySQL database
?>

 

I might be totally off, but I'm not really sure what to search for. I know in wordpress databases they usually have wp_.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/
Share on other sites

Actually I've worked out how to create a table, but how would I make it so that the table's name is the directory's name. I've found how to do it in php;

<?php
$junk=getcwd();
$pass="0"; $long=0;
$tv=strlen($junk); $dvd=$tv-1;
while ($pass=="0")
{
$vhs=substr($junk,$dvd,1);
if ($vhs==chr(47)) {$pass=1;}
if ($vhs==chr(92)) {$pass=1;}
$long=$long+1; $dvd=$dvd-1;
}
$vhs=substr($junk,$dvd+2,$long-1);
print "$vhs";
?>

 

and that'll give the directory, and the table creating script is;

 

 

<?php
include("dbinfo.inc.php"); //get settings
mysql_connect($host,$user,$password); //connect to database
@mysql_select_db($database) or die( "Unable to select database"); //select a database or give a error
$query="CREATE TABLE [i]TABLE NAME TO BE DIRECTORY[/i] (checkbox TEXT NOT NULL )"; //create the table checkbox, with type TEXT
mysql_query($query);  //execute it
$query2="INSERT INTO checkbox (checkbox) VALUES ('0')"; //add a 0 to field checkbox
mysql_query($query2);  //execute it
mysql_close(); //close the connection
?>
Finished creating table.

 

How could I do this so that the Table name is that of the directory.

Thanks

There will be multiple checkboxes so

 

/Checkboxes/Monday1/index.php

/Checkboxes/Monday2/index.php

/Checkboxes/Monday3/index.php

/Checkboxes/Monday4/index.php

 

I couldn't give them all the same database details as they'd just overwrite eachother, but I don't want to have to enter the details in each separate one. The database info file is in php, so is there anything I can enter that'll get the name of the directory and use that as the name of the table?

Allow me to suggest you to describe in details what exactly are you trying to accomplish.. what are you trying to design/solve... every post that you have wrote until now is totally confusing and doesn't explain at all what you are trying to do... with a better explanation probably somebody could give you advice.

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.