discuz! Haihe wrote the Discuz forum post call JS PHP code

Source: Internet
Author: User
Calling code

js_bbs.php (placed in the root directory) content
Require ("bbs/config.inc.php");
Connect, select Database
$link = mysql_connect ($dbhost, $dbuser, $DBPW) or Die (' Could not connect: '. Mysql_error ());
mysql_select_db ($dbname) or Die ("Could not elect database");
$fid =$_get["FID"];
Intercept character length
$length = 36;
Prevent Chinese garbled characters
mysql_query ("Set names ' gb2312 '");
Execute SQL query
$query = "Select Tid,subject from Cdb_threads where fid= ' $fid ' ORDER by lastpost desc LIMIT 10";
$result = mysql_query ($query) or Die ("Query failed:". Mysql_error ());
Display results in HTML
while ($myrow = Mysql_fetch_row ($result))
{
printf ("Document.writeln (\")
  • %s
  • \ ") \ n", $myrow [0],cutstr ($myrow [1], $length, "..."));
    }
    Releasing the result set
    Mysql_free_result ($result);
    Close connection
    Mysql_close ($link);
    Intercept character functions
    function Cutstr ($string, $length, $dot = ' ... ') {
    $strcut = ";
    for ($i = 0; $i < $length-strlen ($dot)-1; $i + +) {
    $strcut. = Ord ($string [$i]) > 127? $string [$i]. $string [+ + $i]: $string [$i];
    }
    return $strcut. $dot;
    }
    ?>

    The above describes the discuz! Haihe wrote the Discuz forum post called JS PHP code, including the discuz! aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.