Jump to content

Query a MySql Database & Insert Results As a HTML Meta Tag


transfield
Go to solution Solved by scootstah,

Recommended Posts

Hi,

This is my code.

<?php 
include("/home/path/to/my/website/db_connect.php"); //connect to the database

$result2 = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * from `wp2_search_queries` WHERE (`query` NOT LIKE '%:%') AND (`query` NOT LIKE '%+%') AND (`query` NOT LIKE '%\.%') AND (`query` NOT LIKE '%\'%') AND (`query` NOT LIKE '%\?%') AND (`source` NOT LIKE '%mywebsite.com%') GROUP BY `query` order by `query_date` DESC limit 0,7");

while($rows2=@mysqli_fetch_array($result2)){
$keywords = "{$rows2['query']}".",";
echo $keywords;
}
?>

Now, I want to insert $keywords into the following HTML meta tag:

<meta name='keywords' content='<?php echo $keywords;?>'>

How do I get the 'final product' to look like this?

<meta name='keywords' content='keyword1,keyword2,keyword3,keyword4,keyword5,keyword6,keyword7'>

Please show me the code as I may not be able to understand your instructions. Thanks

 

Link to comment
Share on other sites

Dont ever do this:

 

@mysqli_fetch_array

 

Errors are your friend, don't hide them.

 

 

$GLOBALS["___mysqli_ston"]

 

I have never seen this but it doesnt seem right. Anyone have anything to say about this?

 

My other question is, OP, Why are you doing dynamic keyword stuffing? It is not going to help your SEO and may even get you penalized.

 

Google’s own Matt Cutts warned webmasters about SEO keyword stuffing and over optimization at SXSW last week, saying:

"We are trying to level the playing field a bit. All those people doing, for lack of a better word, over optimization or overly SEO – versus those making great content and a great site. We are trying to make GoogleBot smarter, make our relevance better, and we are also looking for those who abuse it, like too many keywords on a page, or exchange way too many links or go well beyond what you normally expect. We have several engineers on my team working on this right now."

Edited by benanamen
  • Like 1
Link to comment
Share on other sites

Dont ever do this:

 

@mysqli_fetch_array

 

Errors are your friend, don't hide them.

 

 

 

I have never seen this but it doesnt seem right. Anyone have anything to say about this?

 

My other question is, OP, Why are you doing dynamic keyword stuffing? It is not going to help your SEO and may even get you penalized.

Good advice regarding the hiding of errors using @. I appreciate that, thanks.

 

With regards to keyword stuffing, I plan to "stuff" it with a maximum of 7 keywords. I don't think that's a bad thing to do...correct me if I'm wrong.

 

Why dynamic? Well here's a weird (& probably a warped) idea I have. I'm tracking organic keyword searches from Google which resulted an actual click to my site. I reckon that if the user clicked on my link displayed by Google during an organic search, then that keyword must have:

1. Appeared on the 1st few pages of Google (which means that I am ranking very well for this keyword).

2. My website was very relevant to the needs of the user (otherwise he wouldn't have clicked my link displayed on Google's search results).

 

Is there a better way to identify a good quality meta keyword that this? 

Link to comment
Share on other sites

With regards to keyword stuffing, I plan to "stuff" it with a maximum of 7 keywords. I don't think that's a bad thing to do...correct me if I'm wrong.

 

What your not getting is that search engines are looking at your page content and not your keywords. Your really just wasting your time. Not saying keywords don't matter at all. There are more important things a good search engine is looking at. Page content, How many people link to you (This is a big one). You need to do lots of research in the ever changing world of SEO and always keep researching. If you really want to know what keywords work, set up an adwords account.

Edited by benanamen
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.