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

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.

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

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.