Monday, August 23, 2010

how to select limited characters from a table column in mysql

In MySQL you can draw on the LEFT() thread function to choose a fix digit of qualities as of the left of a specific data column which permits me to obtain an appearance at the primary little utterances in comment to estimate. In this situation I am fetching 100 characters.

<\?php
      $query = "select id, left(content, 100), title from tablename";
      $res = mysql_query($query);
      while($data = mysql_fetch_array($res))
      {
             echo $data['id'];
             echo $data['left(content, 100)'];
             echo $data['title'];
             echo "<\br>";
      }
?>