Last 10 Post Help

Started on the old forum in January 2008 · view the original in the archive · old links redirect here

12 replies · 1,317 views · started 18 years ago · 1 min read

7 participants
jayasanka Developer · 128 posts #1
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&who=$item[0]&sid=$sid\">$item[1]</a> [size="1"]Staff Points: $item[2][/size]";
   $lnk = "<a href=\"index.php?action=viewtpc&sid=$sid&tid=$item[0]&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='".$uid."'"));
    $themeimageset = mysql_fetch_array(mysql_query("SELECT themedir FROM ibwf_iconset WHERE id='".$thid[0]."'")); 
    echo "<a href=\"index.php?action=main&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 ...

[

mcKeny Developer · 130 posts #3

YEAH wiz is right you got a bunch of error why not try doing this

$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&sid=$sid&tid=$item[0]\">$item[1]</a>"; 
}

and you get that error cause you didn't define the variable $item_per_page so its equivalent to 0

R.M.C

PHP Adovocate B)

MEENU Newbie · 2 posts #5

YEAH wiz is right you got a bunch of error why not try doing this

$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&sid=$sid&tid=$item[0]\">$item[1]</a>"; 
}

and you get that error cause you didn't define the variable $item_per_page so its equivalent to 0

but this code gives the posts in a jumbled manner how to arrange them pls help frnd. External image (may be gone)

mcKeny Developer · 130 posts #6

ORDER BY id LIMIT 1,10 DESC

R.M.C

PHP Adovocate B)

adeii Newbie · 8 posts #7

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

Guest #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. .

rukiya Lead · 569 posts #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. .

code for last 10 posts

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&sid=$sid&tid=$item[2]&go=last\">$a</a>";
      $d = "<a href=\"index.php?action=viewuser&sid=$sid&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&sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo "</card>";
}
Guest #11

code for last 10 posts

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&sid=$sid&tid=$item[2]&go=last\">$a</a>";
      $d = "<a href=\"index.php?action=viewuser&sid=$sid&who=$item[1]\">$b</a>";
      echo "$c By $d
";
}

echo "</p>";
  echo "<p align=\"center\">";
  echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
  echo "</card>";
}

I alredy try and this is working External image (may be gone) Thanks Rukiya External image (may be gone)

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close