网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > WordPress
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 218.2.66.169
Old 2012-06-11, 09:41 PM
car car is offline
高级会员
 
Join Date: 2006-05-14
Posts: 534
car 正向着好的方向发展
Default WordPress调用Discuz的终极方法

WordPress是世界上使用最多的搭建博客的开源程序,而做SEO的朋友都知道,SEO的终极方法就是用户帮我们进行网站的更新,所以搭建一个论坛,然后调用论坛里面的帖子可以达到全站更新的目的,所以我们做SEO的都应该知道WordPress调用Discuz的方法。
虽然WordPress调用Discuz的方法多种多样,但是这里提供的方法是最好也是最有效的方法,代码如下
Code:
<ul>
 
        <?php
 
            //截取utf8字符串
 
            function utf8Substring($str, $from, $len){
 
                return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.
 
                    '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s','$1',$str);
 
            }
 
            //建立数据库链接
 
            $conn = *mysql_connect("localhost", "数据库用户名", "数据库密码") or die("数据库链接错误");
 
            //指定要链接的数据库
 
            mysql_select_db("数据库", $conn);
 
            //使用UTF-8中文编码;
 
            mysql_query("set names 'UTF-8'");
 
            //指定版块的所有文章中取10条最新帖子
 
    $SQL="SELECT tid,subject FROM 表名 where fid in (2,37,38,39,40,41,42,43,44,45) ORDER BY tid DESC LIMIT 0,10";
 
            $query=mysql_query($SQL);
 
            //循环显示结果
 
            while($row=mysql_fetch_array($query)){
 
                    echo "<li><span class=titlel><a class=title title=".$row[subject]." href=http://www.seo-adwords.org/seo-adwords-".$row[tid]."-1-1.html target=_blank>".
 
                        utf8Substring($row[subject], 0, 40)."</a></span></li>";
 
                }
 
    //关闭链接
 
    mysql_close($conn);
 
                ?>
 
    </ul>
如果调用的时候出现了错误试着把上面代码的如下部分删除:

Code:
  //关闭链接
 
    mysql_close($conn);
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 02:09 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.