Jump to content

[SOLVED] display part of a text record


ROCKINDANO

Recommended Posts

Can you elaborate on what you exactly want? There isn't one answer...SUBSTR() can be used for a fixed number of characters...to do an entire sentance, you will have to find a period in the text, etc

 

here are a list of MySQL string functions too:

http://dev.mysql.com/doc/refman/5.1/en/string-functions.html

 

p.s. - are you using PHP? you will most likely have a wider variety of options on your scripting language

Link to comment
Share on other sites

yes i am using php. well its a page that shows a list of stories. this page should show a brief part of the story. for example the first sentence or so. then right after that it has read more as a link. once you click on read more the next page should display that story in its full.

Link to comment
Share on other sites

well i did that now it doesn't display anything just the title.

 

this is a snippet of where it displays the title, first sentence and the read more link.

 

			if(!isset($news_id))
					{						
						$query = "SELECT * FROM news ORDER BY news_id DESC";
						$result = mysql_query($query);

						//goes through all records in database and retrieves the need ones.
						while($r=mysql_fetch_array($result))
						{	
					   //the format is $variable = $r["nameofmysqlcolumn"];
					   		$news_id=$r["news_id"];
					      $fulldesc =$r["fulldesc"];

					   //displays all info only first three
					   		print "<p><b style='color:#9F0000'>".$title=$r["title"]."</b><br />";
//						   		print $description=$r["description"];
							print substr($row['fulldesc'],0,strstr($row['fulldesc'],'.'));
					  		print "&#8230; <a href='newsevents.php?news_id={$news_id}'>read more »</a></p>";
						}//end while loop

				  }//end if

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.