PDA

View Full Version : [SOLVED] Wordpress: read from an existing database



RobikShrestha
July 23rd, 2011, 06:33 PM
Suppose I have an existing database with:

article name, article and date of article (published date.) i.e. I manually inserted the values through phpMyAdmin.

Now, if I want to build a website using wordpress which posts those articles, how do I do that? i.e. I want the website to automatically display all the articles in the database, without the admin having to post the articles individually.

Bachstelze
July 23rd, 2011, 06:42 PM
Basically, you don't. WP expects the data to be in a specific format (name of columns, data type, etc.). Unless the database you have is a dump froma previous WP database, you will have a lot of trouble putting it in the correct format. What I would do it:

1. Create WordPress site
2. Enable e-mail posting
3. Make a PHP script that reads the existing database, parses the entries and sends them with mail() to the posting address
4. ...
5. PROFIT?

For the posting date, you can make another script that reads your database, gets the posting date of each article and modifies the posting date of the corresponding article in the WP database.

RobikShrestha
July 23rd, 2011, 06:45 PM
I guess then, I would just have to use the wordpress to generate "a template" for the website, then edit the php documents to read the articles from the database. Or is there an easier way?

Actually, the articles are generated by some java program and then stored in the database, if I store those articles in the same database as the wordpress, will the wordpress be able to read the new articles?

Bachstelze
July 23rd, 2011, 06:50 PM
Yes, but you will probably have to modify your Java program so that it creates the database entried in the format WP expects. It will probably be simpler than the other way around (modifying WP so that it understands tha entries your Java program makes).

RobikShrestha
July 23rd, 2011, 06:55 PM
I am very new to WP. I started it just today.

I am a bit confused on how to customize WP to match with java. WP seems to have pre-defined table entries.

edit1: I will try to insert the articles into the WP database through a java program. Now will the wordpress automatically recognize the articles and post them, and allow the users to comment on them?

slavik
July 23rd, 2011, 07:06 PM
try asking in the wordpress forums, this is not a wordpress support site.

RobikShrestha
July 23rd, 2011, 07:10 PM
Thanks for the suggestion. I had tried Netbeans forums for Netbeans issues but I got much more help from here. Anyway, I will post the question in that forum too.

Bachstelze
July 23rd, 2011, 07:31 PM
edit1: I will try to insert the articles into the WP database through a java program. Now will the wordpress automatically recognize the articles and post them, and allow the users to comment on them?

Yes, if they are in the correct format. Otherwise you may encounter some weird errors.

RobikShrestha
July 24th, 2011, 01:17 AM
This is funny, I haven't had a single reply in wordpress forum while so many in this forum.

I will try to insert in db now. By correct format, is it just that I need to fill all the table attributes? Or should the value within the attributes be in some format (which does not make sense to me).

Bachstelze
July 24th, 2011, 01:30 AM
I will try to insert in db now. By correct format, is it just that I need to fill all the table attributes? Or should the value within the attributes be in some format (which does not make sense to me).

Both. By "correct format" I mean for example that text should use the correct enoding for the database if you use non-ASCII characters, or that numbers or dates should be in the same format WP uses. Basically your manually-added entries should be indistinguishable from entries that are added when you make a post in WP.

RobikShrestha
July 24th, 2011, 02:54 AM
Thanks for the replies.
So in conclusion, I create a web site with word press. I inserted data into its database from java program. Then when I opened the web site the posts were posted. So, I will mark this thread as solved.