Forum Moderators: coopster
Here is the code I am using:
// check start point and limit number of rows shown
$start = $_GET["start"];
$result = mysql_query("SELECT * FROM entries order by id desc limit 0,3");
$numposts = mysql_numrows($result);
// display entries if they exist.
if (mysql_numrows($result)!=0) {
while ($myrow = mysql_fetch_array($result)) {
// snip the entry
$snip = $myrow["entry"];
if (strlen($snip >= 80)) {
$snip = substr($snip, 0, 80);
$snip = trim(substr($snip, 0, strrpos($snip, ' '))).'...';
}
// display the item
echo "<p>".$myrow["title"]."<br>".$snip."</p>\n";
}
}
Can anyone see what is wrong there? Why is the snip not happening?
if (strlen($snip >= 80))
should be
if (strlen($snip) >= 80)
// check start point and limit number of rows shown
$start = $_GET["start"];
$result = mysql_query("SELECT * FROM entries order by id desc limit 0,3");
$numposts = mysql_numrows($result);
// display entries if they exist.
if ($numposts!=0) {
while ($myrow = mysql_fetch_array($result)) {
// snip the entry
$snip = $myrow["entry"];
if (strlen($snip) >= 80) {
$snip = substr($snip, 0, 80);
$snip = trim(substr($snip, 0, strrpos($snip, ' '))).'...';
}
// display the item
echo "<p>".$myrow["title"]."<br>".$snip."</p>\n";
}
}