Is it ok to get keywords and description from database? - php

This isn't really a coding question, but I wanted to ask about what is more efficient and what should I use.
I am making a tutorials website, and each tutorial is brought up onto a page "blog.php" on which all data comes from the database. Now I have two ways I can fill in the meta keywords tag and meta description tag.
I was thinking of making 2 new columns in the blogs table, keywords, and description, and the meta tags would be filled up correspondingly from the database, and the database would get the keywords and description from user input (whover wrote the blog). I know how I would do this but is this efficient? Because I heard search engines have a harder time reading stuff from the database, so I wanted to make sure.
So I can use that OR do you recommend that I use JQuery to get text from the title tag and use that type of stuff? It would be really great because I was hoping to use PHP to make it dynamic, but if I should use Jquery and javascript then please tell which is better!
Thanks!

Search engines never read stuff from the database.
They read only HTML generated by your script.
Storing keywords and description in database is all right.
The only thing you have to change in your setup is database design.
There shouldn't be keywords field in the blog table. Instead of that there should be keywords table and keywords_blog lookup table to link between keywords and tutorials.

Search engines don't read from your database, only you do! What search engines have sometimes struggled with is dyanmic pages, i.e. a page like blog.php where the content changes via the query string, so blog.php?id=1 etc.
What many people do in this situation is use human readable URLs along with rewriting etc so your URLs might be
/blog/what-i-did-today
/blog/why-x-sucks
or similar. This would all be server by blog.php (or index.php or whatever) and then you can easily allow your bloggers to add their own keywords and descriptions via your database.
But do you really need to write your own? There is a ton of software out there that you can just download and install that does this already. Do you need to re-invent the wheel?

Related

Store both BBCode and HTML version in database?

On Stackoverflow I've found questions about storing BBCode OR HTML into the database, but what about storing both? For example, I would create posts DB table with two columns: body_bbcode & body_html.
In body_bbcode I would store original post submitted by a user (forum member), and in body_html I would store parsed (HTML) version of that post.
So, for displaying forum posts I would use body_html, but for editing & quoting (replying with quote) I would use body_bbcode.
The reason why I want to do this is because the parser is using regex and without body_html it would need to convert at least 15 forum posts per topic page. Correct me if I'm wrong, but that can cause performance issues?
On the other hand, I didn't see anyone doing like this so I'm wondering what are the disadvantages of this approach, besides taking up more space in the Database?
Also, I am thinking of adding a new column in which I would store plain text version for search purposes, so that the tags themselves aren't searched (for example body_text).
The reason why I want to do this is because the parser is using regex and without body_html it would need to convert at least 15 forum posts per topic page. Correct me if I'm wrong, but that can cause performance issues?
A well designed bbcode regex will not hinder performance in any meaningful way.
Do not create "duplicate" columns for bbcode text and html text.
A major problem you run into with your suggested approach is that you will inevitably change your html code. (E.g., add a class to html links, change iframe dimensions of youtube embeds, etc.) Then you're stuck trying to update the data in the html column which would be problematic.

How to mass change the link in WordPress?

the thing is, In my WordPress website i have posted some links to some post. and the domain name of the links have been changed and they are so much in an amount in total of 549 posts.the link is like this yourdomain.com/free-access/ and they are in a button. so any suggestions how can i change the domain name.
thanks
The best way to change the domain names in posts is to export and download the database backup. Search and replace the domain name occurrences and save the sql file. Then import the sql file.
You can do a global search and replace with a plugin. There are others but I suggest Better Search and Replace. It's in the WordPress Repository and is free.
Before you make a change like this you should run a full backup, just in case anything goes wrong.
The plugin in question will let you do a dry run, that is you enter your search text and replace text, select the tables you want to search in and then check the box to Run as Dry Run. This will show you where your changes would be made without actually making them, so you're sure you've entered the right search and replace terms.
You can also make changes like this directly on the database tables using SQL but I strongly recommend against it. This tool is much safer.

Using Mysql to store articles as Wordpress does

I am looking for a way to store article in database in the same format as it would appear on the website. Could anyone here kindly explain how to store the entire article in database and later display the same on web? I suppose I need some mechanism to accomplish this. But I couldn't find any solution for the past 4 days despite extensive searching all over. Please help.
Storing html in a database is easy enough, but trying to store whole webpages is not the right way to do it...
Many WYSIWYG editors send html through for you to store, depending on your requirements typically you would store these in a VARCHAR to TEXT column in your (MySQL) database.
Simply insert the data into your database with a normal INSERT statement.

PHP Localization and dynamic data

So I need to make a site available in different languages. Using PHP 5.x and MySQL 5.x. I believe I will be using gettext which seems fine for static text throughout the site but what about dynamic data that is stored in the db? Im referring to things like stories, events business listings etc. How do I get those to display in a different language? My initial thought was in the backend have them be able to enter multiple versions of a story, event or listing, one for each language they want to use on the site. But there could be thousands of entries times how many languages they want to show. Is there a better solution/idea that someone can point me to?
Also another issue I was thinking is currently the site allows you to search events/stories/listings, how would that work in different languages? Im assuming if someone selected the site to show in spanish they are going to use spanish words to search the site, but if the information in the db is in english I dont know that would work. Any suggestions on that?
If you want the stories to be correct in all languages, then you need them stored in all languages and provide the backend to do the translations or enter the stories on different languages as you initially thought.
If you don't like that, you might add the google translate element in your pages, to provide automatic (not correct) translation.
For the search question, I would only search for the keywords in the fields of the database in the same language as the user. If Joe is visiting your page in English, only look for the search terms in title_en, content_en, description_en fields of your database (or the ones with language='en' if you have one row per article and translation in the database, instead of one row per article (with all translations inside)). Obviously, this does only work if you put all the translations on the database.
The best solution I have seen described is this.
As i18n CMS sites as you describe are in a constant state of flux, with new articles being added, some of which have had translations, in some languages.
If an article in a chosen language has not yet been translated then show a default language (English?).
Then pick any ideas which appeal to your case:
a) If showing a default article in English also throw onto the page an input box and invite your audience to translate it for you.
b) If showing a default article in English also put on the page an offer to send the content to google translate as well as doing a) above
c) put a bounty on the translation and optionaly do a) and/or b) above.

Multiple xml feeds, sql match

I'm developing a store which gets its product info from lots of xml feed, I'll have maybe 3000 products in my database. I'll do it using a cronjob.
What I'd like to do is write posts, lets say a general post about picking the best TV set for yor family. Then I'd make a mysql match whitch should take the posts title and content and match it to the thousands of products in my database and retrieve the closest match to display on my post.
I'm thinking of this becouse having alot of xml with different nods, categories would be very hard for me to propely filter them using php.
Now, do you think thats a good ideea? content, performace wise?
Do you think mysql match could do it? Maybe use some other method?
Should I store all the product info like price, description, reviews in a single table field and use it for the mysql match?
Is there a better way I can do this?
Any ideea is very appreciated, I need to sort this out, make a plan before I start coding and waiting time.
What you are trying to do is awful with pure XML.
I strongly suggest you to leave this task to your Database in this case MySQL, basically your 3rd point.
With MyISAM table you can set up the full text search if you need a bit more complex query based on affinity.

Categories