transfield Posted October 27, 2015 Share Posted October 27, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/298858-query-a-mysql-database-insert-results-as-a-html-meta-tag/ Share on other sites More sharing options...
Solution scootstah Posted October 27, 2015 Solution Share Posted October 27, 2015 Add the keywords to an array: $keywords = array(); while($rows2=@mysqli_fetch_array($result2)){ $keywords[] = htmlspecialchars($rows2['query'], ENT_QUOTES); }And then implode it:<meta name='keywords' content='<?php echo implode(',', $keywords);?>'> 1 Quote Link to comment https://forums.phpfreaks.com/topic/298858-query-a-mysql-database-insert-results-as-a-html-meta-tag/#findComment-1524468 Share on other sites More sharing options...
benanamen Posted October 27, 2015 Share Posted October 27, 2015 (edited) 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 October 27, 2015 by benanamen 1 Quote Link to comment https://forums.phpfreaks.com/topic/298858-query-a-mysql-database-insert-results-as-a-html-meta-tag/#findComment-1524469 Share on other sites More sharing options...
transfield Posted October 27, 2015 Author Share Posted October 27, 2015 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? Quote Link to comment https://forums.phpfreaks.com/topic/298858-query-a-mysql-database-insert-results-as-a-html-meta-tag/#findComment-1524479 Share on other sites More sharing options...
benanamen Posted October 27, 2015 Share Posted October 27, 2015 (edited) 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 October 27, 2015 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/298858-query-a-mysql-database-insert-results-as-a-html-meta-tag/#findComment-1524483 Share on other sites More sharing options...
QuickOldCar Posted October 27, 2015 Share Posted October 27, 2015 opengraph data will do you more good, that's the summarized content of the page. Quote Link to comment https://forums.phpfreaks.com/topic/298858-query-a-mysql-database-insert-results-as-a-html-meta-tag/#findComment-1524504 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.