character limit per page

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

    character limit per page

    PHP Code:
    else if($action=="viewart")
    {
        
    $id = $_GET["id"];
     
    $cid = $_GET["cid"];
    $artid = $_GET["artid"];
    $cinfo = mysql_fetch_array(mysql_query("SELECT name from ibwf_readart WHERE id='".$id."'"));
        
    addonline(getuid_sid($sid),"Reading $cinfo[0]","articles.php?action=$action");
       
        
     
    $tinfo = mysql_fetch_array(mysql_query("SELECT name, authorid, crdate, id from ibwf_readart WHERE id='".$id."'"));
        
    $tnm = htmlspecialchars($tinfo[0]);
        echo 
    "<card id=\"main\" title=\"$tnm\">";
        echo 
    "<p align=\"left\">";
    echo 
    "<b>$cinfo[0]</b><br/>";

        
    $tmstamp = $tinfo[2];
        
    $tmdt = date("D,dMy-h:i:s a",$tmstamp);
          
         echo 
    "$tmdt<br/>";
    $unick = getnick_uid($tinfo[1]);
        
    $usl = "<a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$tinfo[1]&amp;browse?\">$unick</a>";

    echo 
    "$usl2 Submitted by: $usl<br/>";
      
    $tid = $_GET["artid"];
      
    $go = $_GET["go"];
    $uid = getuid_sid($sid);
        
        
    $num_pages = getnumpages2($artid);
        if(
    $page==""||$page<1)$page=1;
        if(
    $go!="")$page=getpage_go2($go,$artid);
        
    $posts_per_page = 5;
        if(
    $page>$num_pages)$page=$num_pages;
        
    $limit_start = $posts_per_page *($page-1);
        
    $vws = $tinfo[3]+1;
     
    ///////from here
        
    if($page==1)
        {
          
    $posts_per_page=4;

          
    $ttext = mysql_fetch_array(mysql_query("SELECT authorid, text, crdate FROM ibwf_readart WHERE id='".$id."'"));
         
    $pst2 = parsemsg($ttext[1], $sid);
     
    $unick = getnick_uid($ttext[0]);
     if(
    substr_count($ttext[1],"[br/]")<=1000){
        
    $text = str_replace("[br/]","<br/>",$ttext[1]);

     }

     echo 
    "$text<br/>";
      
    mysql_query("UPDATE ibwf_readart SET vws='".$vws."' WHERE  id='".$id."'");
      
    mysql_query("INSERT INTO ibwf_view2 SET uid='".$uid."', artid='".$artid."', actime='".time()."'");     
      }
      if(
    $page>1)
      {
        
    $limit_start--;
      }
      
    $sql = "SELECT id, text  FROM ibwf_artpost WHERE artid='".$artid."' ORDER BY crdate LIMIT $limit_start, $posts_per_page";
      
    $posts = mysql_query($sql);
      while(
    $post = mysql_fetch_array($posts))
      {
        
    $unick = getnick_uid($post[2]);
       
        
    $usl = "<br/><a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$post[2]&amp;browse?\">$unick</a>";
        
    $pst = parsemsg($post[1], $sid);
     
     if(
    substr_count($post[1],"[br/]")<=1000){
        
    $pst = str_replace("[br/]","<br/>",$post[1]);
     
     }
       echo 
    "<br/>$hm $pst<br/>";
        
     
      }
        
        
    ///to here
       
     
    if($page>1)
        {
          
    $ppage = $page-1;
          echo 
    "<a href=\"articles.php?action=viewart&amp;page=$ppage&amp;sid=$sid&amp;artid=$artid&amp;cid=$cid&amp;id=$id\">«PREV</a> ";
        }
        if(
    $page<$num_pages)
        {
          
    $npage = $page+1;
          echo 
    "<a href=\"articles.php?action=viewart&amp;page=$npage&amp;sid=$sid&amp;artid=$artid&amp;cid=$cid&amp;id=$id\">Next»</a>";
        }
        echo 
    "<br/>Page $page of $num_pages";
        if(
    $num_pages>2)
        {
          
    $rets = "<br/>Jump to page: <input name=\"pg\" format=\"*N\" size=\"3\"/>";
            
    $rets .= "<anchor>[GO]";
            
    $rets .= "<go href=\"articles.php?browse?\" method=\"get\">";
            
    $rets .= "<postfield name=\"action\" value=\"$action\"/>";
            
    $rets .= "<postfield name=\"cid\" value=\"$cid\"/>";
         
    $rets .= "<postfield name=\"id\" value=\"$id\"/>";
      
    $rets .= "<postfield name=\"artid\" value=\"$artid\"/>";
            
    $rets .= "<postfield name=\"sid\" value=\"$sid\"/>";
            
    $rets .= "<postfield name=\"page\" value=\"$(pg)\"/>";
            
    $rets .= "</go></anchor>";

            echo 
    $rets;
        }
       
     if(
    canaddart($uid, $id))
        {
     echo 
    "<br/><a href=\"articles.php?&amp;action=newart2&amp;sid=$sid&amp;id=$artid&amp;artid=$artid&amp;cid=$cid\">Add more</a>";

    }
     
    $tmsg = getpmcount(getuid_sid($sid));
      
    $umsg = getunreadpm(getuid_sid($sid));
      if(
    $umsg>0)
      {
      echo 
    "<br/><a href=\"inbox.php?action=main&amp;sid=$sid&amp;browse?\">New Private msg($umsg/$tmsg)</a>";
      }
      
    $countpics = mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM iwbf_cwart WHERE artid='".$artid."'"));
     echo 
    "<br/><a href=\"articles.php?&amp;action=artcom&amp;sid=$sid&amp;id=$id&amp;artid=$id&amp;cid=$cid\">Comments($countpics[0])</a>";
    echo 
    "<br/>";
       echo 
    "<a href=\"articles.php?&amp;action=dload&amp;sid=$sid&amp;id=$id&amp;artid=$id\">Download</a>";
    echo 
    "<br/>";
       echo 
    "<a href=\"articles.php?&amp;action=viewall&amp;sid=$sid&amp;id=$id&amp;artid=$id&amp;cid=$cid\">Fastread</a>";
    echo 
    "<br/>";
    $cinfo = mysql_fetch_array(mysql_query("SELECT name from ibwf_articles WHERE id='".$cid."'"));
       echo 
    "<a href=\"articles.php?&amp;action=kindat&amp;sid=$sid&amp;cid=$cid\">$cinfo[0]</a>";
    echo 
    "<br/>";
    $ttext = mysql_fetch_array(mysql_query("SELECT authorid, text, crdate FROM ibwf_readart WHERE id='".$id."'"));
    $unick = getnick_uid($ttext[0]);
    $unick2 = getnick_uid($post[2]);
     echo 
    "<a href=\"articles.php?&amp;action=vall&amp;sid=$sid&amp;who=$ttext[0]&amp;cid=$cid&amp;cid=$cid&amp;id=$artid&amp;artid=$artid\">All articles of $unick</a>";
    echo 
    "<br/>----------<br/>";
    echo 
    "<a href=\"articles.php?action=articles&amp;sid=$sid&amp;browse?\">";
        echo 
    "Articles</a><br/>";

    echo 
    "<br/>";   
    echo 
    "<a href=\"index.php?action=main&amp;sid=$sid&amp;type=send\">";
    echo 
    "Main menu</a>";
      echo 
    "</p>";
        echo 
    "</card>";
    } 
    i cant make limit to less than 500 characters every page,

    i mean if the whole article text is 2300 characters then the article cut in 5 pages, of course the 5th page only got 300 characters

    hope my English is good LoL
    Did I help you?
    You can help me too
    Your donations will help me finance my studies.

    #2
    something like this:
    PHP Code:
    else if($action=="viewart") 
    { 
        
    $id = $_GET["id"]; 
     
    $cid = $_GET["cid"]; 
    $artid = $_GET["artid"]; 
    $cinfo = mysql_fetch_array(mysql_query("SELECT name from ibwf_readart WHERE id='".$id."'")); 
        
    addonline(getuid_sid($sid),"Reading $cinfo[0]","articles.php?action=$action"); 
        
         
     
    $tinfo = mysql_fetch_array(mysql_query("SELECT name, authorid, crdate, id, text from ibwf_readart WHERE id='".$id."'")); 
        
    $tnm = htmlspecialchars($tinfo[0]); 
        echo 
    "<card id=\"main\" title=\"$tnm\">"; 
        echo 
    "<p align=\"left\">"; 
    echo 
    "<b>$cinfo[0]</b><br/>"; 

        
    $tmstamp = $tinfo[2]; 
        
    $tmdt = date("D,dMy-h:i:s a",$tmstamp); 
           
         echo 
    "$tmdt<br/>"; 
    $unick = getnick_uid($tinfo[1]); 
        
    $usl = "<a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$tinfo[1]&amp;browse?\">$unick</a>"; 

    echo 
    "$usl2 Submitted by: $usl<br/>"; 
      
    $tid = $_GET["artid"]; 
      
    $go = $_GET["go"]; 
    $uid = getuid_sid($sid); 
         
    $num = count_chars($tinfo[4],1);
    $num_pages = ceil($num / 500);
        
    //$num_pages = getnumpages2($artid); 
        
    if($page==""||$page<1)$page=1; 
        if(
    $go!="")$page=getpage_go2($go,$artid); 
        
    $posts_per_page = 5; 
        if(
    $page>$num_pages)$page=$num_pages;

    $end = $page * 500;
    $start = $end - 500; 
    $newtext = substr($tinfo[4], $start, $end);


        
    $limit_start = $posts_per_page *($page-1); 
        
    $vws = $tinfo[3]+1; 
     
    ///////from here 
        
    if($page==1) 
        { 
          
    $posts_per_page=4; 

          
    $ttext = mysql_fetch_array(mysql_query("SELECT authorid, text, crdate FROM ibwf_readart WHERE id='".$id."'")); 
         
    $pst2 = parsemsg($ttext[1], $sid); 
     
    $unick = getnick_uid($ttext[0]); 
     if(
    substr_count($newtext,"[br/]")<=1000){ 
        
    $text = str_replace("[br/]","<br/>",$newtext); 

     } 

     echo 
    "$text<br/>"; 
      
    mysql_query("UPDATE ibwf_readart SET vws='".$vws."' WHERE  id='".$id."'"); 
      
    mysql_query("INSERT INTO ibwf_view2 SET uid='".$uid."', artid='".$artid."', actime='".time()."'");      
      } 
      if(
    $page>1) 
      { 
        
    $limit_start--; 
      } 
      
    $sql = "SELECT id, text  FROM ibwf_artpost WHERE artid='".$artid."' ORDER BY crdate LIMIT $limit_start, $posts_per_page"; 
      
    $posts = mysql_query($sql); 
      while(
    $post = mysql_fetch_array($posts)) 
      { 
        
    $unick = getnick_uid($post[2]); 
        
        
    $usl = "<br/><a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$post[2]&amp;browse?\">$unick</a>"; 
        
    $pst = parsemsg($post[1], $sid); 
      
     if(
    substr_count($post[1],"[br/]")<=1000){ 
        
    $pst = str_replace("[br/]","<br/>",$post[1]); 
      
     } 
       echo 
    "<br/>$hm $pst<br/>"; 
         
      
      } 
         
        
    ///to here 
        
     
    if($page>1) 
        { 
          
    $ppage = $page-1; 
          echo 
    "<a href=\"articles.php?action=viewart&amp;page=$ppage&amp;sid=$sid&amp;artid=$artid&amp;cid=$cid&amp;id=$id\">«PREV</a> "; 
        } 
        if(
    $page<$num_pages) 
        { 
          
    $npage = $page+1; 
          echo 
    "<a href=\"articles.php?action=viewart&amp;page=$npage&amp;sid=$sid&amp;artid=$artid&amp;cid=$cid&amp;id=$id\">Next»</a>"; 
        } 
        echo 
    "<br/>Page $page of $num_pages"; 
        if(
    $num_pages>2) 
        { 
          
    $rets = "<br/>Jump to page: <input name=\"pg\" format=\"*N\" size=\"3\"/>"; 
            
    $rets .= "<anchor>[GO]"; 
            
    $rets .= "<go href=\"articles.php?browse?\" method=\"get\">"; 
            
    $rets .= "<postfield name=\"action\" value=\"$action\"/>"; 
            
    $rets .= "<postfield name=\"cid\" value=\"$cid\"/>"; 
         
    $rets .= "<postfield name=\"id\" value=\"$id\"/>"; 
      
    $rets .= "<postfield name=\"artid\" value=\"$artid\"/>"; 
            
    $rets .= "<postfield name=\"sid\" value=\"$sid\"/>"; 
            
    $rets .= "<postfield name=\"page\" value=\"$(pg)\"/>"; 
            
    $rets .= "</go></anchor>"; 

            echo 
    $rets; 
        } 
        
     if(
    canaddart($uid, $id)) 
        { 
     echo 
    "<br/><a href=\"articles.php?&amp;action=newart2&amp;sid=$sid&amp;id=$artid&amp;artid=$artid&amp;cid=$cid\">Add more</a>"; 

    } 
     
    $tmsg = getpmcount(getuid_sid($sid)); 
      
    $umsg = getunreadpm(getuid_sid($sid)); 
      if(
    $umsg>0) 
      { 
      echo 
    "<br/><a href=\"inbox.php?action=main&amp;sid=$sid&amp;browse?\">New Private msg($umsg/$tmsg)</a>"; 
      } 
      
    $countpics = mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM iwbf_cwart WHERE artid='".$artid."'")); 
     echo 
    "<br/><a href=\"articles.php?&amp;action=artcom&amp;sid=$sid&amp;id=$id&amp;artid=$id&amp;cid=$cid\">Comments($countpics[0])</a>"; 
    echo 
    "<br/>"; 
       echo 
    "<a href=\"articles.php?&amp;action=dload&amp;sid=$sid&amp;id=$id&amp;artid=$id\">Download</a>"; 
    echo 
    "<br/>"; 
       echo 
    "<a href=\"articles.php?&amp;action=viewall&amp;sid=$sid&amp;id=$id&amp;artid=$id&amp;cid=$cid\">Fastread</a>"; 
    echo 
    "<br/>"; 
    $cinfo = mysql_fetch_array(mysql_query("SELECT name from ibwf_articles WHERE id='".$cid."'")); 
       echo 
    "<a href=\"articles.php?&amp;action=kindat&amp;sid=$sid&amp;cid=$cid\">$cinfo[0]</a>"; 
    echo 
    "<br/>"; 
    $ttext = mysql_fetch_array(mysql_query("SELECT authorid, text, crdate FROM ibwf_readart WHERE id='".$id."'")); 
    $unick = getnick_uid($ttext[0]); 
    $unick2 = getnick_uid($post[2]); 
     echo 
    "<a href=\"articles.php?&amp;action=vall&amp;sid=$sid&amp;who=$ttext[0]&amp;cid=$cid&amp;cid=$cid&amp;id=$artid&amp;artid=$artid\">All articles of $unick</a>"; 
    echo 
    "<br/>----------<br/>"; 
    echo 
    "<a href=\"articles.php?action=articles&amp;sid=$sid&amp;browse?\">"; 
        echo 
    "Articles</a><br/>"; 

    echo 
    "<br/>";    
    echo 
    "<a href=\"index.php?action=main&amp;sid=$sid&amp;type=send\">"; 
    echo 
    "Main menu</a>"; 
      echo 
    "</p>"; 
        echo 
    "</card>"; 
    } 
    Will need slight work on updating pages .... but something like that
    Last edited by something else; 17.11.09, 00:46. Reason: UPDATED CODE

    Comment


      #3
      i got error in line

      $num_pages = ceil($num/500);

      Fatal error</b>: Unsupported operand types in <b>/home/kepyas/public_html/articles.php
      im not familiar with ceil, btw while waiting a reply im trying to make this work, thanks for this something else
      Did I help you?
      You can help me too
      Your donations will help me finance my studies.

      Comment


        #4
        ceil() rounds upwards. eg: if something was 4.2 then ceil would change it to 5.

        might be cos needs extra brackets $num_pages = ceil(($num/500)); for the devision
        or otherwize im guessing ceil isnt on all php versions could try:
        $num_pages = round(($num/500+1)); ..... sorry brains not working at moment due to lack of sleep

        Comment


          #5
          LoL no problem about that, atleast you try to help
          Did I help you?
          You can help me too
          Your donations will help me finance my studies.

          Comment


            #6
            ceil()is used for forums, for example.
            Echo "Page $page of ceil($totalpage)";
            mysterio.al - programming is a functional art

            Comment

            Working...
            X