3

I have finally finished coding a project with an HTML form for file upload, and a large PHP file that submits a 200 field CSV into my database. It first uploads to a staging table and then splits the data into smaller tables.

This all works perfectly but I'm having problems with the next step: This is needed to run on a wordpress site that already exists. I have a database just for this project with tables for users, clients, staging, meters, etc. I need all of these tables in their own database because these users are separate from the WP users.

I found a plugin that allows you to insert PHP into pages, but I need to know how to work with a custom database in WP, I've only ever worked with the actual database. Any help is greatly appreciated.

2
  • do you need to connect & use both the databases in your website? Commented Mar 31, 2017 at 1:18
  • Yes, the main database is being used currently. We set up a subdomain from the site to use for this project where two different people will upload CSV files at different times into the same database (our custom one) and it needs to be kept separate if possible Commented Mar 31, 2017 at 14:07

2 Answers 2

3

Include wordpress db file in your script 'wp-admin/includes/upgrade.php' and then call

global $wpdb;
$wpdb->query($your_query_string);

This way you can use wordpress database. But go through wordpress once so you will be aware of tables. Because wordpress save specific data to specific tables, say - any informartion about user to user_meta table.

If you are trying to insert new users then you may need to enter data into user table.

Another method is there.

You can open your wordpress theme's function.php then you can write scripts to enter your data or what ever fuctionality you are looking for. And I think that is a better way to work with wordpress.

Sign up to request clarification or add additional context in comments.

Comments

2

If you want to use php, try this tutorial: https://www.w3schools.com/php/php_ref_mysqli.asp

If you are developing wordpress plugins check out the wordpress codex: https://codex.wordpress.org/Creating_Tables_with_Plugins

This is going to take a bit of research on your part. Good luck!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.