dtyqeoc70733 2011-11-11 10:29
浏览 10

关键字与特定页面链接 - PHP + mySQL

I have this task, and I would like your opinion to how do you think it would be best tackled.

He wants something like an adwords database, to have the ability to tell the system that particular words should be linked to a particular page on a website.

For example, keywords: stack, stackoverflow, stack overflow, overflow stack should link to http://www.abc.com/stackoverflow

The tricky part about this is that this will not work in the search box, and you can assign additional keywords to each page. This will need to work by updating all the content in the website, and assign a particular link if it matches any of those keywords.

The website is currently running in PHP and using mySQL. I would appreciate any feedback.

  • 写回答

1条回答 默认 最新

  • drau89457 2011-11-11 23:39
    关注

    I can`t get the idea with the search box. Otherwaise, use a SELECT statement from PHP to generate a java array. Use onload event to manage words.

        <?php
    $con = mysql_connect("YourServerName","YourUserName","YourUserPassword");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("YourDatabaseName", $con);
    
    $result = mysql_query("SELECT * FROM YourKeywordsTable
    LIMIT 30"); //You don`t know how many words you have on the page
    
    echo "<script type='text/javascript'>var no_array = new Array(";
    $myArray='';
    while($row = mysql_fetch_array($result))
      {
      echo ", " . $row[0] . ", " . $row[1];
      echo "]";
      }
    echo substr($myArray,1).+");</script>";
    ?>
    

    //This code will generate your the javascript that you will use to replace words with links in your page content

    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序