Jump to content

Need to limit the amount of text loaded into a cell


cnl83

Recommended Posts

I have a some news that im loading into a cell. You can see the actual page here. (take a look at the section towards the bottom that says CHADS TEST). http://www.poshinteriors.com/09/news/

 

I only want to be able to display no more than 250 Characters. Does anyone know a nifty way to do this in a cell?

 

    <td height="110"></td>
    <td colspan="2" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="imported/news.gif">
      <!--DWLayoutTable-->
      <tr>
        <td width="32" height="38"> </td>
        <td width="258"> </td>
        <td width="11"> </td>
      </tr>
      <tr>
        <td height="89"> </td>
        <td valign="top"><p align="left"><?php
include_once( dirname(__FILE__) . '/fastnews-code.php' );
$fn = new fastNews();
echo $fn->display();
?></a> </p></td>
          <td> </td>
      </tr>
      
    </table></td>

I'm assuming:

<?php
include_once( dirname(__FILE__) . '/fastnews-code.php' );
$fn = new fastNews();
echo $fn->display();
?>

is the part that prints your news?

If so, try using this:

<?php
include_once( dirname(__FILE__) . '/fastnews-code.php' );
$fn = new fastNews();
echo substr($fn->display(), 0, 250);
?>

(note the substr)

Oh yeah, I just looked at your html source and the php in that cell actually outputs:

<SCRIPT LANGUAGE="JavaScript">
function fn_HideElement( elementName ){
ele = document.getElementById( elementName );
if( ! ele ){
	alert( 'cannot find ' + elementName );
	return;
	}
ele.style.display = "none";
}
function fn_ShowElement( elementName ){
ele = document.getElementById( elementName );
if( ! ele ){
	alert( 'cannot find ' + elementName );
	return;
	}
ele.style.display = "block";
}
</SCRIPT>
<STYLE>
ul#phpFastNews {
list-style-type: none;
margin: 0.5em 0;
padding: 0;
}
ul#phpFastNews li {
list-style-type: none;
margin: 1em 0;
padding: 0;
}
</STYLE>

<UL ID="phpFastNews">

<A ID="fn-loginBar" HREF="#" ONCLICK="fn_ShowElement('fn-loginForm'); fn_HideElement('fn-loginBar'); return false;">Login</A>
<LI ID="fn-addForm" STYLE="display: none;">
<H3>Add News Item</H3>
<FORM METHOD="post" ACTION="http://www.poshinteriors.com/09/news/fastnews-code.php">
<INPUT TYPE="hidden" NAME="fn_action" VALUE="add">
<INPUT TYPE="text" SIZE="48" NAME="subject" VALUE="News Subject"><BR>
<TEXTAREA ROWS="6" COLS="48" NAME="message">News Text</TEXTAREA><BR>

<INPUT TYPE="submit" VALUE="Add">
</FORM>
</LI>
<LI ID="fn-loginForm" STYLE="display: none;">
<H3>Login</H3>
<FORM METHOD="post" ACTION="http://www.poshinteriors.com/09/news/fastnews-code.php">
<INPUT TYPE="hidden" NAME="fn_action" VALUE="login">
Password: <INPUT TYPE="password" SIZE="24" NAME="password" VALUE=""><BR>
<INPUT TYPE="submit" VALUE="Login">

</FORM>
</LI>
<LI ID="fn-view-2">
<H3>Chads Test</H3>
<I>15 Jun 2009 5:54 pm</I>
<BR>
my Test
<BR>

</LI>

<LI ID="fn-edit-2" STYLE="display: none;">
<H3>Edit News Item</H3>
<FORM METHOD="post" ACTION="http://www.poshinteriors.com/09/news/fastnews-code.php">
<INPUT TYPE="hidden" NAME="fn_action" VALUE="update">
<INPUT TYPE="hidden" NAME="id" VALUE="2">
<INPUT TYPE="text" SIZE="48" VALUE="Chads Test" NAME="subject"><BR>
<TEXTAREA ROWS="6" COLS="48" NAME="message">my Test</TEXTAREA><BR>
<INPUT TYPE="submit" VALUE="Update"><BR>

</FORM>
</LI><LI ID="fn-view-1">
<H3>Today's Hot News</H3>
<I>2 Sep 2008 4:43 pm</I>
<BR>
Hello! It is a really nice weather today. It is only getting better with phpFastNews script! Get it up and running in minutes!
<BR>

</LI>

<LI ID="fn-edit-1" STYLE="display: none;">
<H3>Edit News Item</H3>
<FORM METHOD="post" ACTION="http://www.poshinteriors.com/09/news/fastnews-code.php">
<INPUT TYPE="hidden" NAME="fn_action" VALUE="update">
<INPUT TYPE="hidden" NAME="id" VALUE="1">
<INPUT TYPE="text" SIZE="48" VALUE="Today's Hot News" NAME="subject"><BR>
<TEXTAREA ROWS="6" COLS="48" NAME="message">Hello! It is a really nice weather today. It is only getting better with phpFastNews script! Get it up and running in minutes!</TEXTAREA><BR>
<INPUT TYPE="submit" VALUE="Update"><BR>

</FORM>
</LI>
<DIV STYLE="font-size: 0.75em; margin: 1em 0 0 0;">Powered by <A HREF="http://www.phpfastnews.com">phpFastNews</A> - fast and free news display script</DIV>
</UL>

 

 

I'm not sure where the actual news is outputted from.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.