Querying only 400 characters from the database won't work
I have this line of code:
$query=$db->prepare("SELECT post_id, title, LEFT(body, 400), category FROM
posts INNER JOIN categories ON categories.category_id=posts.category_id
ORDER BY post_id DESC LIMIT $start, $per_page");
The LEFT(body,400) won't query 400 characters only, it will query all but
the last word. This is the code I use to echo the query (its in a while
loop w/ db)
<p><?php
$body_sub = substr($body, 0). "...<a href='post.php?id=$post_id'>
Continue Reading ¨</a>";
echo nl2br($body_sub);
?></p>
No comments:
Post a Comment