Announcement

Collapse
No announcement yet.

last post code optimize

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • mohammad6006
    started a topic last post code optimize

    last post code optimize

    i create this code for show last active posts for non-vb page can you help me for optimize this code?

    PHP Code:
    <?php
    ## CUSTOMIZE SETTINGS FOR YOUR SITE ##
    $db_host "xxxx"// Change this if your MySQL database host is different.
    $db_name 'xxxx'// Change this to the name of your database.
    $db_user 'xxxxx'// Change this to your database username.
    $db_pw 'xxxxx'// Change this to your database password.
    $db_pre ""// Tables prefix
    $forum_url "http://forum.xxxx.com/"// Change this to reflect to your forum's URL.
    $forum_id ""
    $limit "20"// Number of posts displayed.
    $txtlimit "120"// This is the character limit.
    #######################################

    // Connecting to your database

    mysql_connect($db_host$db_user$db_pw
    OR die (
    "Cannot connect to your database user"); 
    mysql_select_db($db_name) OR die("Cannot connect to your database"); 

    if (
    $forum_id) {
        
    $forumid "AND forumid=$forum_id";
    }

    if (
    $limit) {
        
    $limited "LIMIT $limit";
    }


    $thread_sql mysql_query("SELECT threadid, lastpost, lastposter, title FROM thread WHERE visible=1 AND open=1 AND forumid<>32 ORDER BY lastpost DESC LIMIT 0,5");
    for(
    $i 0$i<5$i++)
    {
      
    $tid = @mysql_result($thread_sql,$i,0);
      
    $lastpost = @mysql_result($thread_sql,$i,1);
      
    $lastposter = @mysql_result($thread_sql,$i,2);
    //  $replaycount = @mysql_result($thread_sql,$i,9);
    //  $views = @mysql_result($thread_sql,$i,17);
      
    $psql mysql_query("SELECT postid FROM post WHERE threadid='$tid' ORDER BY postid DESC LIMIT 0,1");
      
    $pid = @mysql_result($psql,0,0);
      
    $title = @mysql_result($thread_sql,$i,3);
      
    $title substr($title,0,$txtlimit);
    $sitename "http://forum.xxxxx.com/";
    $sitelink "showthread.php?t=$tid&p=$pid#post$pid";

    ?>

    i use top code in a non-vb page

    i dont want use database user and password in this file and connect directly to database
    Last edited by mohammad6006; Thu 28 Jun '12, 4:54am.

Related Topics

Collapse

  • backpages
    Database Over Limit
    by backpages
    We are using vBulletin 5.2.4. Unfortunately, we are in a Catch 22 situation regarding out database. Our host only allows databases of 1gb or under. Our database got too big and now it won't work, it says...
    Thu 31 Aug '17, 8:23am
Working...
X