How to select just the first 200 characters of a field
I have a table named "news", wher every colums in the "newstext" field are very large. I wonder how to select just the first 200 characters of every field to show on my web page. I tryed this "$result = @mysql_query("SELECT LEFT(newstext,200) FROM news");". It did not work. I am using this code from Kevin Yank's book:
<?php
// Request the text of all the jokes
$result = @mysql_query("SELECT JokeText FROM Jokes");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
// Display the text of each joke in a paragraph
while ( $row = mysql_fetch_array($result) ) {
echo("<p>" . $row["JokeText"] . "</p>");
}
Bookmarks