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.
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.
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!
Related
I am new to wordpress coding and need some help regarding fetching some data from different database which is not wordpress database and show on wordpress website. Let me make it more clear,
I have two CMS installed
1. WordPress
2. CRM
In CRM I have some user data which i want to display on wordpress. I searched web but almost each answer is showing retrieving data from wordpress database itself. If you have any way to do it please suggest.
There isn't an "as is" solution, every database structure of every CRM is different.
You will have to create your own custom database queries, and output the data into variables that you can use to create new queries on the other database.
Next, you will want to format your data and present it into a page.
what i understand from your post is thatyou want to show contents of a different database in your wordpress site. i think i have a solution which is not so good but it should work.
you can create a custom plugin for your wordpress. sole purpose of that plugin would be fetching data form that db and show it in you wp site.
make a custom connection in your plugin to connect it with the database you want.
I used to have a Wordpress website a few years ago. After getting hacked, I decided to create my own PHP script and extract the necessary data from my Wordpress Installation and keep the same URL structure. Now, a few years later, I want to move back to Wordpress for various reasons. My site has over 2500 articles, and manually importing these articles will be a pain, and I want to keep the same URL structure, as to not lose any SEO.
Here is my SEO structure
https://www.example.com/post-id/post-title-all-lower-case/
I have a database with the following values:
post id
post url (the url slug)
category id
post title
post content
etc..
I can easily create an xml or rss feed with these values for the 2500 posts. But I don't know how to import this content to wordpress. Anyone got any ideas on how I can go through a smooth transition?
I just need this content imported. Creating the theme and everything else is the easy part.
All help is greatly appreciated!
EDIT: SOME PROGRESS!
I have uploaded all my content to a new wordpress installation. Each post has a custom field with a unique number. This number MUST be the post_id.
How do I make it so that I make this custom field the post_id of that post?
All help is greatly appreciated!
You can use this wordpress plugin for safe migration.
https://wordpress.org/plugins/duplicator/
I did something like this a couple of years ago, using MS Excel to concatenate the cells to export to a csv file we could load directly to the mysql db using PHPMyAdmin. We were also doing categories, which involved various tables. For posts, I think you can load directly to the wp_posts db table. I'd create a single post in WP, look to see what table counts change. The look at the tables that changed to see how you would need to populate a csv file to load your content.
I am developing a WordPress site for a client and they would like me to setup a custom page that allows logged in users to query a custom table in the WordPress database. I'll be naming the custom table 'inspectors' and will import the data from a CSV file.
I've found this helpful tutorial on doing this
But the 'fly in the ointment' is that they want the results to be displayed according to location - so the user would enter a postal code or town and will get results for inspectors that are located within a 50 k radius. I'm pretty sure I could manage a basic query to the custom table, but getting it to return location-based results is beyond me.
Is it even possible - and if so, is it worth the time and effort it would take to make it happen - or is there a simple solution I just don't know about?
Also, they also would like me to create a custom form (that is available only to the admin user role) so they can update the info from WordPress and not have to update the info in the spreadsheet. They'd like to be able to export the data in the table to CSV easily too ...
Thanks for any help on this!
Refer the below link and write your own custom queries.
http://codex.wordpress.org/Class_Reference/wpdb
I am a long time Wordpress user looking to use the tool as a CMS to generate a website which will have individual posts about hundreds of specs on products that I have stored in a backend MySQL table. Is there a plugin or a tool that will help me auto generate these posts? For each post, I would like it to have the same format of title (one column) so that the URL will look like: http://www.domain.com/product1specs etc. Each post will contain a description (another column) and show a graph (data stored in another column).
Or do I even need to create posts? Is there a way to do this dynamically? So if someone goes to www.domain.com/product1 than it will automatically look in the database to find out what it should display for product1?
I believe there are other ways to do this with an PHP framework such as Code Igniter but I would like to stick with Wordpress because I am familiar with it and have other Wordpress plugins/themes I would like to leverage.
Any tips would be greatly appreciated!
I don't know of a plugin but take a look at this answer which basically required the same thing:
How to migrate from Yii to Woocommerce Wp, Still keep to old database (table,rows)
I am trying to find a way to hook several satellite WordPress installations into a centralized installation of WordPress in order to pull post data and custom field meta from two custom post types from the central installation and display this data on the satellite sites.
Is there any way to create a database connection to another WordPress database either on the same server, or on a DIFFERENT server, and then use STANDARD WORDPRESS LOOP METHODOLOGY to retrieve and display data from that second WordPress database, whilst still maintaining the ability to retrieve posts/pages from the original native database?
Sorry if this is a complicated question. I have been Googling for several hours and have even tried to write a couple of solutions myself which failed spectacularly.
Would most definitely appreciate any help and advise and if anyone could post some code ideas, that would be great!