I've gotten a lot better at PHP since I last posted, but I still need some help here and there. (If you help me, you will be credited in the eventually GPL-ed source code)
There's a project that I'm working on that is largely database-driven.
Here's how the database will eventually be set up:
There are multiple educational classes offered by the provider of the website.
Each class will have its own table in the database. Originally, everything would have been kept in one big table, but I scrapped that idea to improve performance. (by keeping everything in separate tables, I figure that queries will run faster since the database engine won't have to slog through everything to find a particular record.
However, I'm having trouble setting up the targeting system.
I'm planning for the user to be able to select which table a query will be applied to by choosing the table from a drop-down list that will automatically update as tables are added/removed.
However, here is my current problem:
1. I'm not sure how to list all tables in the database in a HTML drop down menu. I'm certain that it involves using while , but I'm not really sure how to go about it.
I'm also not sure how to do this as with plain text, either. I wrote a mini script to test it, but it didn't work either (output was: "Resource ID #3)
FYI, I tried to hide the database login stuff in an external PHP file kept in a non-public directory like someone told me to do once, but I wasn't sure how to reference a protected directory in the script, and my attempt didn't work. (I tried to use one that was above the public_html directory in the file tree) Help with that would also be appreciated.
Thanks in advance.
There's a project that I'm working on that is largely database-driven.
Here's how the database will eventually be set up:
There are multiple educational classes offered by the provider of the website.
Each class will have its own table in the database. Originally, everything would have been kept in one big table, but I scrapped that idea to improve performance. (by keeping everything in separate tables, I figure that queries will run faster since the database engine won't have to slog through everything to find a particular record.
However, I'm having trouble setting up the targeting system.
I'm planning for the user to be able to select which table a query will be applied to by choosing the table from a drop-down list that will automatically update as tables are added/removed.
However, here is my current problem:
1. I'm not sure how to list all tables in the database in a HTML drop down menu. I'm certain that it involves using while , but I'm not really sure how to go about it.
I'm also not sure how to do this as with plain text, either. I wrote a mini script to test it, but it didn't work either (output was: "Resource ID #3)
Code:
<?php /* define our database parameters */ $dbhost = 'localhost'; $dbuser = [snip] $dbpass = [snip] $con = mysql_connect($dbhost, $dbuser, $dbpass); if (!$con) { die('Could not connect: ' . mysql_error()); } $dbname = [snip] mysql_select_db($dbname); $listthem = mysql_query("SHOW TABLES;"); echo $listthem; ?>
FYI, I tried to hide the database login stuff in an external PHP file kept in a non-public directory like someone told me to do once, but I wasn't sure how to reference a protected directory in the script, and my attempt didn't work. (I tried to use one that was above the public_html directory in the file tree) Help with that would also be appreciated.
Thanks in advance.