PHP-定义从行中的数据库显示的限制角色

时间:2019-05-22 13:49:53

标签: php

我正在开发一个新闻网站,我想限制$ row ['text']行中的角色数量,但我不能。我也尝试实现此解决方案Limiting the output of PHP's echo to 200 characters,但在我的代码中不起作用。还可以帮我吗?谢谢。

在此代码中,我可以从另一个页面正常工作。

<div class="col-sm-12" id="texto_urgeirica"><?php echo substr ($row['texto'], 0, 2);?></div>

我遇到的问题是此页代码的一部分。

<?php          
    if(mysqli_num_rows($result) > 0){
        while($row = mysqli_fetch_array($result)){
            echo "<div class='container' id='fadein2'>";
                echo "<div class='row'>";
                    echo "<div class='col-sm-3'>";
                         echo "<a href='admin_destaques_noticia.php?id={$row['id']}'><img src='upload/destaques/{$row['image']}' id='imagem' class='imagem img-fluid'></a>";
                    echo "</div>";
                    echo "<div class='col-sm-9'>";
                        echo "<a href='admin_destaques_noticia.php?id={$row['id']}' id='url_sem_linha'><p class='destaques_lista'>{$row['titulo']}</p></a>";
                        echo "<a href='admin_destaques_noticia.php?id={$row['id']}' id='url_sem_linha'><p class='destaques_lista'>substr ({$row['texto'],0,20});</p></a>";
                        echo "<a href='admin_destaques_noticia.php?id={$row['id']}' id='url_sem_linha'><p class='ler_noticia'>Clique para ler a notícia</p></a>";
                        echo "<p></p>";
                    echo "</div>";
                    echo "<div class='col-sm-6' align='right'><a href='admin_destaques_editar.php?update_id={$row['id']}' class='btn btn-warning'>Editar</a></div>";
                    echo "<div class='col-sm-6'><a href='?delete_id={$row['id']}' class='btn btn-danger'>Eliminar</a></div>";
                echo "</div>";
            echo "<div class='linha_paginas'></div>";
            echo "</div>";
            echo "<p></p>";
        }
    } else{
        echo"<h2>Não existe</h2>";
    }
?>

0 个答案:

没有答案