Rumah >pembangunan bahagian belakang >tutorial php >手把手教你做关键词匹配项目(搜索引擎)---- 第一天,教你做----_PHP教程
第一天
收到需求,需求如下:
1. 收集关键词,构建关键词词库。
收到这个任务,第一想法,这还不简单吗? 马上动手创建一个关键词录入界面,保存到数据库。 第一步完成了,哈哈大笑了一天,没想到事情原来如此的简单。
数据库配置文件: config.php
<span>$database_host</span> = 192.168.1.1 <span>$database_user</span> =<span> xiaoshuaishuai </span><span>$database_password</span> =<span> xiaoshuaishuai </span><span>$database_charset</span> = "utf-8"
后台逻辑处理: keywords.php
<?<span>php </span><span>include</span> "config.php" <span>$keywords</span> = <span>$_REQUEST</span>["keywords"<span>]; </span><span>$con</span> = <span>mysql_connect</span>(<span>$database_host</span>,<span>$database_user</span>,<span>$database_password</span><span>); </span><span>mysql_query</span>("SET NAMES '<span>$database_charset</span>'",<span>$conn</span><span>); </span><span>mysql_select_db</span>("dict",<span>$conn</span><span>); </span><span>foreach</span>(<span>$keywords</span> <span>as</span> <span>$keyword</span><span>){ </span><span>//</span><span>save $keyword to database</span> <span>$sql</span> = "insert into keywords(word) values ('<span>$keyword</span>')"<span>; </span><span>mysql_query</span>(<span>$sql</span>,<span>$conn</span><span>); } </span><span>mysql_close</span>(<span>$conn</span>);
现在 百度推广有精确、短语、广泛三种匹配方式,,一般来说黄金组合匹配方式是:广泛匹配+搜索词报告+否定关键词。流量来说的话就是 广泛>短语>精确啦,可以根据你们呢的实际情况进行设置!
如果要精确匹配,需要ABC都带引号。