Go Back   Directory Critic Forums > Directory Talk > Running Your Directory
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 10-26-2007, 12:03 PM   #1 (permalink)
Critic
Administrator
 
Critic's Avatar
 
Join Date: Aug 2007
Location: Australia
Posts: 125
Critic is a jewel in the roughCritic is a jewel in the roughCritic is a jewel in the roughCritic is a jewel in the rough
Default Simple PHP script for updating meta description tags

This morning I was looking at my webguide PHPLD database. I noticed that none of the categories had meta description tags. This is not good, because directory pages do not have muscle actual content on the pages it's important to have something that the search engines can use in the SERPs. And I don't know about you, but when I'm searching what is written below the URL plays a key role in helping me choose whether to click or not.

So, I wrote a little script that you can upload to your server, change a few things and give all your categories meta tags.

PHP Code:

// Enter your database settings here
define('DB_HOST''localhost');
define('DB_NAME''YOUR-DB-NAME');
define('DB_USER''YOUR-DB-USER');
define('DB_PASSWORD''YOUR-DB-PASS');

// enter your meta desc string here
$meta_description 'The top 10 websites for %CATNAME%. %CATNAME% resources and links page.';

$db mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
mysql_select_db(DB_NAME);

$res mysql_query("SELECT * FROM PLD_CATEGORY");

while(
$row mysql_fetch_array($res)) {
    
    
// create new meta description tag
    
$new_meta_desc str_replace('%CATNAME%'$row['TITLE'], $meta_description);
    
    
// update the row
    
mysql_query("UPDATE PLD_CATEGORY SET META_DESCRIPTION = '$new_meta_desc' WHERE ID = '$row[ID]'");
    


echo 
'done!'
All you have to do is enter your DB information (user/pass etc) and write your desired meta description tag. You don't want all your meta descriptions to be the same so you can add %CATNAME% in your meta description which will be replaced with the actual category name. You can see I used:

The top 10 websites for %CATNAME%. %CATNAME% resources and links page.

So this would be:

The top 10 websites for Cars and Automotive. Cars and Automotive resources and links page.

Simple, but effective. Enjoy!
Critic is offline   Reply With Quote
Old 10-28-2007, 02:43 PM   #2 (permalink)
Meti
CEO, Web Catalogue
 
Meti's Avatar
 
Join Date: Oct 2007
Location: Sweden
Posts: 103
Meti is on a distinguished road
Default

Damien,

I was just taking a look at e-Sweden, powered by phpLD (v3) and I noticed there's a option to rebuild the meta tags for categories, though I doubt the free version (v2) supports this feature, so my question would be, which version did you try that with?

Regards,
Meti
__________________
Web Catalogue - Quality Web Directory
Meti is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 10:54 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright Directory Critic 2005-2007