Results 1 to 9 of 9

Thread: Update Keyword Mod

  1. #1
    Join Date
    Nov 2004
    Posts
    1,822

    Default Update Keyword Mod

    The tag feature is cool, but if you import information to your database you often dont have keywords for the listings.

    copy the code below and save it as "getkeywords.php" and then run it in your web browser to populate all entries with empty keywords in your directory. Zubby helped me with this a few months back and i thought i would add it here for others to take advantage of

    Code:
    <?
    
    include "application.php";
    
    $sql = "select link_id, url from idx_link where keywords = ''";
    $rs = $dbConn->Execute($sql);
    while ($row = $rs->FetchRow()) {
      echo "$row[url]<br />";
      flush();
      $content = HttpRequest($row["url"]);
      preg_match_all('/<[\s]*meta[\s]*name="?' . '([^>"]*)"?[\s]*' . 'content="?([^>"]*)"?[\s]*[\/]?[\s]*>/si', $content['html'], $match);
      for ($i = 0; $i < count($match[1]); $i++) {
        if (strtolower($match[1][$i]) == "keywords") {
          $keywords = trim(strip_tags($match[2][$i]));
          if ($keywords != '') {
            $keywords = addslashes($keywords);
            $sql = "update idx_link set keywords = '$keywords' where link_id = '$row[link_id]'";
            echo $sql . "<hr />";
            $dbConn->Execute($sql);
            flush();
          }
        }
      }
    }
    echo "Done.";
    
    ?>
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  2. #2
    Join Date
    May 2007
    Location
    NJ, United States
    Posts
    1,651

    Default

    Thanks for sharing this Insprireme!!!

  3. #3
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    no problem you need 5.4 for it to work, forgot to mention that.
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  4. #4
    Join Date
    Mar 2007
    Posts
    47

    Thumbs up

    inspireme if I changed all references from "keywords" to "description" would this harvest meta description tags from url's that don't have any description added in database? same as it does for keywords.

  5. #5
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    should do, meta descriptions are usually pretty junk though.
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  6. #6
    Join Date
    Jun 2007
    Location
    Quebec
    Posts
    242

    Smile

    TY works good

  7. #7
    Join Date
    Oct 2007
    Posts
    31

    Default keywords = '' --> keywords IS NULL ?

    I ran the script and was suprised that it finished after updating only a couple of links. In my database, most links with missing tags keywords are NULL.

    Therefore, shouldn't:

    $sql = "select link_id, url from idx_link where keywords = ''";

    rather be:

    $sql = "select link_id, url from idx_link where keywords IS NULL";

    ?

  8. #8
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    Or perhaps this would work?

    $sql = "select link_id, url from idx_link where keywords = ''NULL";

    This script is used a lot by users that are uploading their own database, and typically the field keywords is blank. Of course you can change it to work for your own situation.

  9. #9
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    NULL and '' are completely different, most situations will mean that your database will have keywords as '' if its blank. Looks like you imported, or have a non standard setup, jsut change the query as posted above for your situation.
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

Similar Threads

  1. how to urlencode keyword?
    By vsevedko in forum v5.x
    Replies: 0
    Last Post: 09-13-2006, 09:37 AM
  2. Keyword
    By gspinney in forum v5.x
    Replies: 17
    Last Post: 07-15-2003, 10:24 PM
  3. Google Seach Keyword?
    By Hart_House in forum v5.x
    Replies: 1
    Last Post: 07-06-2003, 08:14 AM
  4. How to encode keyword
    By binto in forum v5.x
    Replies: 6
    Last Post: 06-05-2003, 07:22 AM
  5. Replies: 4
    Last Post: 10-23-2002, 06:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •