Jump to content

limit the character that fetched


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");?>


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...