参见英文答案 > How do you pull first 100 characters of a string in PHP6个
我在数据库表,标题和描述中有两个字段.我在循环中显示php中的数据.
我的代码:
$sql = "select * from sightseeing";
$i = 1;
$res = mysql_query($sql,$conn);
if( mysql_num_rows($res) > 0) {
while($row = mysql_fetch_array($res))
{
echo "
我想只显示描述字段中的前50个字符.怎么做?
最佳答案
试试这个
$sql = "select * from sightseeing";
$i = 1;
$res = mysql_query($sql,$conn);
if( mysql_num_rows($res) > 0) {
while($row = mysql_fetch_array($res))
{
echo "
本文来自网络,不代表青岛站长网立场。转载请注明出处: https://www.0532zz.com/html/shujuku/mysql/20200920/9544.html