Jump to content

limit the character that fetched


TheCatapult

Recommended Posts

Hi, I'm currently seeking it it is possible to limit the characters fetched from the database. For instance, there is 10000 characters and I would like to show only the first 255 character. Here's my code:

<?$username="";$password="";$database="";mysql_connect("",$username,$password);@mysql_select_db($database) or die( "Unable to select database");$id="$_GET['id']";$query="SELECT * FROM news WHERE id='$id'  ORDER BY id DESC LIMIT 3";$result=mysql_query($query);$num=mysql_numrows($result);mysql_close();?><?$i=0;while ($i < $num) {$bck = ($i % 2 == 0 ) ? " style=\"background:#A3FFA3\"" : " style=\"background: #B7B7E8;\"";$id=mysql_result($result,$i,"id");$title=mysql_result($result,$i,"title");$content=mysql_result($result,$i,"content");$poster=mysql_result($result,$i,"poster");?>

Thanks!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...