person287 Posted August 6, 2011 Share Posted August 6, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/ Share on other sites More sharing options...
zavaboy Posted August 6, 2011 Share Posted August 6, 2011 When you say databases, are you referring to database tables? If this is the case, the solution doesn't sound easy. Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1253176 Share on other sites More sharing options...
chintansshah Posted August 6, 2011 Share Posted August 6, 2011 Can you describe your problem in detail? Is your dB available in your mysql server, Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1253304 Share on other sites More sharing options...
person287 Posted August 6, 2011 Author Share Posted August 6, 2011 Yeah, database tables, that's it. What I want to do is have say a database called 'checkboxes' and then tables in the database called; monday1 monday2 monday3 etc Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1253309 Share on other sites More sharing options...
fenway Posted August 6, 2011 Share Posted August 6, 2011 The only reason to have separate DBs is if your data have nothing to do with each other -- ever -- e.g. separate clients. Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1253310 Share on other sites More sharing options...
person287 Posted August 6, 2011 Author Share Posted August 6, 2011 Yeah. The Checkbox part of it that I found used separate databases for every database. I've never looked into combining them so far, but I think it'd be much better if I could. How could I modify the configuration file so that it uses tables? Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1253318 Share on other sites More sharing options...
person287 Posted August 6, 2011 Author Share Posted August 6, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1253321 Share on other sites More sharing options...
fenway Posted August 8, 2011 Share Posted August 8, 2011 Sorry, I'm not following. Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1253967 Share on other sites More sharing options...
person287 Posted August 8, 2011 Author Share Posted August 8, 2011 How could I make it so that the name of the table is the same as the name as the folder? So if the path is /CheckBoxes/Monday1/index.php Then the name of the table will be Monday1 Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1254184 Share on other sites More sharing options...
fenway Posted August 8, 2011 Share Posted August 8, 2011 I don't see why you want to do that. Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1254234 Share on other sites More sharing options...
person287 Posted August 8, 2011 Author Share Posted August 8, 2011 Because what I'd have is one config file which you'd enter in, and then that would replicate to all the folders. If all the checkboxes are being directed to the same table, then they'd end up overwriting eachother. Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1254484 Share on other sites More sharing options...
fenway Posted August 9, 2011 Share Posted August 9, 2011 What do folders have to do with mysql? Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1254991 Share on other sites More sharing options...
person287 Posted August 10, 2011 Author Share Posted August 10, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1255452 Share on other sites More sharing options...
fenway Posted August 10, 2011 Share Posted August 10, 2011 I don't know what any of that means. How do each of those PHP scripts differ? Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1255475 Share on other sites More sharing options...
person287 Posted August 12, 2011 Author Share Posted August 12, 2011 They're each individual checkboxes, and the checkboxes save their states, so for example Monday1 & 3 are checked by 2 & 4 are unchecked. Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1256327 Share on other sites More sharing options...
mikosiko Posted August 12, 2011 Share Posted August 12, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1256399 Share on other sites More sharing options...
fenway Posted August 12, 2011 Share Posted August 12, 2011 Individual PHP files are individual checkboxes? Quote Link to comment https://forums.phpfreaks.com/topic/244027-multiple-sections-in-databases/#findComment-1256473 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.