Forums
This topic is locked
croping a sentence in a repeat region
Posted 10 Feb 2006 02:22:43
1
has voted
10 Feb 2006 02:22:43 Steve Wiedner posted:
Im am trying to crop a sentance using php and a repeat region but the code I have works for the first item but he second one sends an error. Here is the code<?php do { ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle" class="toc_img"><?php echo $row_rsFeature['Photos']; ?></td>
<td valign="top" class="toc_desc"><span class="toc_headers"><?php echo $row_rsFeature['title']; ?></span><br /><?php
function CropSentence ($strText, $intLength, $strTrail)
{
$wsCount = 0;
$intTempSize = 0;
$intTotalLen = 0;
$intLength = $intLength - strlen($strTrail);
$strTemp = "";
if (strlen($strText) > $intLength) {
$arrTemp = explode(" ", $strText);
foreach ($arrTemp as $x) {
if (strlen($strTemp) <= $intLength) $strTemp .= " " . $x;
}
$CropSentence = $strTemp . $strTrail;
} else {
$CropSentence = $strText;
}
return $CropSentence;
}
$strTemp = $row_rsFeature['body'];
$strTemp = CropSentence($strTemp, 250, "..."
print $strTemp;
?> <a href="feat2.php?catid=<?php echo $row_rsFeature['catid']; ?>&id=<?php echo $row_rsFeature['id']; ?>">>>Read More.</a> </td>
</tr>
<tr>
<td colspan="2" class="toc_desc_spacer"></td>
</tr>
</table>
<?php } while ($row_rsFeature = mysql_fetch_assoc($rsFeature)); ?></td>
</tr>
<tr>
<td class="toc_header_cell">Technical</td>
</tr>
<tr>
<td><?php do { ?>
any help is appreciated
Steve
Replies
Replied 13 Feb 2006 19:57:56
13 Feb 2006 19:57:56 Roddy Dairion replied:
Tried it and everything works fine. Can you tell me what error message you were getting??