Forum Moderators: DixonJones

Message Too Old, No Replies

Meta tags

         

stevelibby

6:53 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



Hi All
Can i get my meta tags to be shown via a database and how do i go about doing it, also will i make a difference where search engines are concerned?

ogletree

7:44 pm on Mar 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes it is very easy to put your meta tags in a db. You can use PHP/MySQL. The only one that matters is the description and it does not matter much if you make your site right.

I made the line below an include file located in a directory that is not accessable from the public.

<?PHP $db_server ="serverURL"; $db_name = "DBName"; $username = "User"; $password = "pass"; $dbh = @mysql_connect($db_server,$username,$password) or die ("Connection failed."); $db = @mysql_select_db($db_name) or die ("Connection made. But database '$db_name' was not found.");?>

Next put this on each page


<head>
<?php
$query="SELECT * FROM `META` WHERE PAGE = " . $_SERVER['REQUEST_URI'];
$result=mysql_query($query); $row=mysql_fetch_assoc($result);

echo "<META NAME='description' CONTENT='";
echo $row['DESCRIPTION'];
echo "'>";

echo "<META NAME='keywords' CONTENT='";
echo $row['KEYWORDS'];
echo "'>";

?>
<title>title</title>
</head>

I have not tested this and I could be way wrong but this is what I would do. Of course you have to have MySQL installed with a table that has a record for each file name. If you just have .html file you will need to put

AddType application/x-httpd-php html

in your .htaccess file.

stevelibby

8:01 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



does anyone else use this method? How do they get on in search engines?

ogletree

8:13 pm on Mar 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That way is no different than doing them by hand it is just a way to do it server side. The SE's won't even know you are doing it. Actualy nobody would probably do it this way. It really is no different than by hand except it is more work. You would use this as part of a dynamic site where most of your page came from a db like a content management system but not by itself unless you had some reason for having the meta tags in a db.

stevelibby

8:26 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



would it not be easier to anylize if you were optimizing by having the tags in a db?

ogletree

8:46 pm on Mar 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I was just saying you needed a good reason to do this and that is a darn good one.

stevelibby

9:17 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



Cheers buddy, i try my best. tee-hee.