Jump to content
Fórum Script Brasil
  • 0

Limitar quantidade de caracteres


Elisandro23
 Share

Question

Pessoal eu tenho um script de noticias, e queria que quando aparecerem a noticias no index limitasse o numero de caracteres para que as pessoas clicassem no ler mais e iria para a pagina de noticia. Esse eo script que faz aparecer a noticia no index agora como se faz para limitar o numero de caracteres.

<table maxlenght width="100%" height="25%" <?php 
        include("connection.php"); 
        $result = mysql_query("SELECT * FROM vars"); 
        while($row = mysql_fetch_array($result)) 
        { 
                $twidth=$row['TWidth']; 
                $tbg=$row['TBg']; 
                $bgi=$row['BGI']; 
                $tbord=$row['TBord']; 
                $tbw=$row['TBW']; 
                $nbord=$row['NBord']; 
                $spacing=$row['Spacing']; 
                $dfont=$row['DFont']; 
                $dfsize=$row['DFSize']; 
                $dfc=$row['DFC']; 
                $dalign=$row['DAlign']; 
                $nalign=$row['NAlign']; 
                $tbc=$row['TBC']; 
                $pbc=$row['PBC']; 
                 
        } 
        switch($dfont) 
        { 
                case "1": 
                        $font="font: Arial, Helvetica, sans-serif;"; 
                        break; 
                case "2": 
                        $font="font: Georgia, \"Times New Roman\", Times, serif;"; 
                        break; 
                case "3": 
                        $font="font: Geneva, Arial, Helvetica, sans-serif;"; 
                        break; 
                case "4": 
                        $font="font: \"Courier New\", Courier, monospace;"; 
                        break; 
                case "5": 
                        $font="font: \"Times New Roman\", Times, serif;"; 
                        break; 
                case "6": 
                        $font="font: Verdana, Arial, Helvetica, sans-serif;"; 
                        break; 
        } 
        echo "<table width=\"".$twidth."\" style=\"background: ".$tbg; 
        if($bgi!="NULL") 
        {echo " url('".$bgi."')";} 
        echo " repeat scroll; border: ".$tbc." ".$tbord." ".$tbw.";\">"; 
        $result = mysql_query("SELECT * FROM news ORDER BY Number LIMIT 0,1"); 
         while($row = mysql_fetch_array($result)) 

               
         {
               
   
               
               
               
               echo "<tr><td>"; 
                echo "<table width=\"100%\" style=\"margin-bottom: ".$spacing.";\">"; 
                echo "<tr> 
                                <td align=\"".$dalign."\" colspan=\"2\"><font color=\"".$dfc."\"><span style=\"font: ".$font.";font-size: ".$dfsize."\">".$row['Date']."</span></font></td> 
                        </tr>"; 
                echo "<tr > 
                        <td width=\"10x\"> </td><td align=\"".$nalign."\" style=\"border-bottom: ".$pbc." ".$nbord." 1px;\">".$row['News']."</td> 
                        </tr>"; 
                echo "</table> 
                        </td></tr>"; 
        } 
        echo "</table>"; 
        mysql_close($con); 
?>
</table>

desde já obrigado.

Edited by Elisandro23
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
use a função substr:

substr($row['News'], 0, 100)

Desta forma, você pega os 100 primeiros caracteres do conteúdo do campo 'News'

tentei implementar esse comando e so da erro de syntax mais alguém tem uma ideia ou sabe como arrumar ou me explico o local certo de colocar esse comando.

desde já obrigado

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      150.9k
    • Total Posts
      648.8k
×
×
  • Create New...