Jump to content

Display X Characters


jason97673

Recommended Posts

Hello,

 

I am trying to retrieve data in my PHP page. I can do that successfully, however I would like to retrieve perhaps the first 75 characters of the result set.

 

For example I am making a website that on the front page has the latest news etc. Well right below the latest news I have a <DIV> and it is relatively positioned so I need to make sure the short descriptions of these news excerpts don't end up overlapping my DIV.

 

Should be rather simple as I am sure there is a simple keyword for it somewhere.

 

Any help appreciated.

Link to comment
https://forums.phpfreaks.com/topic/50711-display-x-characters/
Share on other sites

Thanks for the replies.

 

I checked out http://us2.php.net/substr

 

But being that I have

$data = mysql_query("SELECT * FROM info where front_page='1'")
or die(mysql_error());//Display Error message

echo '<table id="news_table">';
echo '<tr>';
echo  '<td><b>Latest News and Announcements</b></td>';
echo '</tr>';

while ($info=mysql_fetch_array( $data ))
{
echo '<tr>';
echo  '<td><a href="showarticle.php?article_id=' .$info['article_id'] .'">' .$info['title'] .'</a></td>';
echo '</tr>';
echo '<tr>';
echo  '<td class="text2">Date Published: <b>' .$info['created'] .'</b></td>';
echo '<tr>';
echo  '<td colspan="2">' .$info['short'] .'</td>';
echo '</tr>';
echo '<tr>';
echo  '<td><hr /></td>';
echo '</tr>';
}
echo '</table>';

 

I'm not very sure how substr() would fit into that very well.

Link to comment
https://forums.phpfreaks.com/topic/50711-display-x-characters/#findComment-249313
Share on other sites

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.