Last 10 Post Help

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

    Last 10 Post Help

    Code:
    else if($action=="last10")
    {
        addonline(getuid_sid($sid),"Last 10 Posts","index.php?action=$action");
    $pstyle = gettheme($sid);
        echo xhtmlhead("Last 10 Posts ",$pstyle);
        echo "
    
    ";
      
      
      
      
      
        echo "[b]Last 10 PostS:[/b]
    ";
      
      
        if($page=="" || $page<=0)$page=1;
        $num_items = regmemcount(); //changable
    
        $num_pages = ceil($num_items/$items_per_page);
        if(($page>$num_pages)&&$page!=1)$page= $num_pages;
        $limit_start = ($page-1)*$items_per_page;
        //changable sql
            $sql = "SELECT id, name FROM ibwf_topics ORDER BY lastpost DESC LIMIT $limit_start, $items_per_page";
    
        $items = mysql_query($sql);
        echo mysql_error();
        if(mysql_num_rows($items)>0)
        {
        while ($item = mysql_fetch_array($items))
        {
          //$lnk = "<a href=\"index.php?action=viewuser&amp;who=$item[0]&amp;sid=$sid\">$item[1]</a> [size="1"]Staff Points: $item[2][/size]";
       $lnk = "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$item[0]&amp;go=last\">$item[1]</a>";
          echo "$lnk
    ";
        }
        }
       
        echo "</p>";
        echo "<p align=\"center\">";
        $thid = mysql_fetch_array(mysql_query("SELECT themeid FROM ibwf_users WHERE id=&#39;".$uid."&#39;"));
        $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id=&#39;".$thid[0]."&#39;")); 
        echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/themes/$themeimageset[0]/home.gif\" alt=\"*\"/>";
    echo "Home</a>";
      echo "</p>";
        echo xhtmlfoot();
    }
    i put dis code and i get error ...

    [
    <div align="center">My Web Community ......... http://pahasara.net



    </div>

    #2
    if u want last 10 order by id in reverse n make LIMIT 10, u have a lot of wrong things in that code above

    Comment


      #3
      YEAH wiz is right you got a bunch of error why not try doing this
      Code:
      $sql =mysql_query("SELECT id,name FROM ibwf_topics  ORDER BY ID LIMIT 1,10 ");
      
      while($item = mysql_fetch_array($sql))
      {
      echo "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$item[0]\">$item[1]</a>"; 
      }
      and you get that error cause you didn&#39;t define the variable $item_per_page so its equivalent to 0

      R.M.C
      ----------
      PHP Adovocate B)

      Comment


        #4
        thankz guyz.................
        <div align="center">My Web Community ......... http://pahasara.net



        </div>

        Comment


          #5
          YEAH wiz is right you got a bunch of error why not try doing this
          Code:
          $sql =mysql_query("SELECT id,name FROM ibwf_topics  ORDER BY ID LIMIT 1,10 ");
          
          while($item = mysql_fetch_array($sql))
          {
          echo "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$item[0]\">$item[1]</a>"; 
          }
          and you get that error cause you didn&#39;t define the variable $item_per_page so its equivalent to 0[/b]



          but this code gives the posts in a jumbled manner how to arrange them pls help frnd.

          Comment


            #6
            ORDER BY id LIMIT 1,10 DESC

            R.M.C
            ----------
            PHP Adovocate B)

            Comment


              #7
              So, what is the right, full working script??

              Comment


                #8
                i need code for 10 last posts too. .
                and if somebody have code for 10 last topic or code for themes where user have posted?For exaple,10 last themes where i posted,that i can look is somebody answer or somethig. .

                Comment


                  #9
                  i need code for 10 last posts too. .
                  and if somebody have code for 10 last topic or code for themes where user have posted?For exaple,10 last themes where i posted,that i can look is somebody answer or somethig. .[/b]
                  code for last 10 posts
                  Code:
                  else if($action=="last10")
                  {
                  
                    addonline(getuid_sid($sid),"Viewing Last 3 Posts","index.php?action=$action");
                      echo "<card id=\"main\" title=\"Last 3 Posts\">";
                      $sql = "SELECT a.name, b.uid, b.tid
                  FROM ibwf_topics a
                  INNER JOIN ibwf_posts b ON a.id = b.tid
                  ORDER BY b.id DESC 
                  LIMIT 0 , 10";
                     echo "
                  
                  ";
                  $items = mysql_query($sql);
                      echo mysql_error();
                      while ($item = mysql_fetch_array($items))
                      {
                        $a = htmlspecialchars($item[0]);
                        $b = getnick_uid($item[1]);
                        $c = "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$item[2]&amp;go=last\">$a</a>";
                        $d = "<a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$item[1]\">$b</a>";
                        echo "[size="1"]$c By $d[/size]
                  ";
                  }
                  
                  echo "</p>";
                  
                  
                    echo "<p align=\"center\">";
                    echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";
                  echo "Home</a>";
                    echo "</p>";
                    echo "</card>";
                  }

                  Comment


                    #10
                    thank you,i will try it now

                    Comment


                      #11
                      code for last 10 posts
                      Code:
                      else if($action=="last10")
                      {
                      
                        addonline(getuid_sid($sid),"Viewing Last 3 Posts","index.php?action=$action");
                          echo "<card id=\"main\" title=\"Last 3 Posts\">";
                          $sql = "SELECT a.name, b.uid, b.tid
                      FROM ibwf_topics a
                      INNER JOIN ibwf_posts b ON a.id = b.tid
                      ORDER BY b.id DESC 
                      LIMIT 0 , 10";
                         echo "
                      
                      ";
                      $items = mysql_query($sql);
                          echo mysql_error();
                          while ($item = mysql_fetch_array($items))
                          {
                            $a = htmlspecialchars($item[0]);
                            $b = getnick_uid($item[1]);
                            $c = "<a href=\"index.php?action=viewtpc&amp;sid=$sid&amp;tid=$item[2]&amp;go=last\">$a</a>";
                            $d = "<a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$item[1]\">$b</a>";
                            echo "[size="1"]$c By $d[/size]
                      ";
                      }
                      
                      echo "</p>";
                        echo "<p align=\"center\">";
                        echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";
                      echo "Home</a>";
                        echo "</p>";
                        echo "</card>";
                      }
                      [/b]


                      I alredy try and this is working
                      Thanks Rukiya

                      Comment


                        #12
                        yes,it work fine

                        Comment


                          #13
                          how to make 10 new topics created? with above coding?
                          Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

                          <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

                          Comment

                          Working...
                          X