Jump to content

Archived

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

chico1st

solved---only print some of an entry

Recommended Posts

Is there any way to print lets say the first 100 characters of a text entry?
To go along with this is there anyway to check the length of a text entry?
Any help would be GGGGRRRRRREAT!

Share this post


Link to post
Share on other sites
1. LEFT( yourColumn, 100 )
2. LENGTH( yourColumn)

Share this post


Link to post
Share on other sites
these dont seem to work for me... and i cant find them in the either the php or mysql manuals
if im supposed to write them how do i take out one character of a string?

Share this post


Link to post
Share on other sites
To elaborate on Fenway's answer about printing 'some' of a field, his method is designed to abstract a defined length of data from a MySQL data field.  Example:

[code]$query = "SELECT left(your_column_name, 100) FROM your_table_name .... "; // retrieve ONLY 100 characters[/code]

Alternatively, you can abstract ALL of the database data and use the substr() function to print a portion of it.  The php manual provides lots of examples of substr() use.

Share this post


Link to post
Share on other sites
MySQL has an equivalent set of string functions as well, depending on what exactly it is that you're doing in the end.

Share this post


Link to post
Share on other sites
heres what i have
$query = "SELECT news.newsID, news.pictureID, news.name AS newsName, news.abstract, [b]left('news.fulltext',100)[/b], date.name " .
  "FROM news, date WHERE news.dateID = date.dateID ORDER BY date.name";

i tried this too
$query = "SELECT news.newsID, news.pictureID, news.name AS newsName, news.abstract, [b]left(news.fulltext,100)[/b], date.name " .
  "FROM news, date WHERE news.dateID = date.dateID ORDER BY date.name";

and i looked at these commands and found nothing
http://www.mysqlfreaks.com/mysql_statements.php
is there another manual?
THANKS!
PS the substr() works i just tried it but i figure this will process faster

Share this post


Link to post
Share on other sites
What makes you think it doesn't work? Granted, you don't have a column alias, so it'll be hard to "find" in your hash.

Share this post


Link to post
Share on other sites
well i couldnt get a result from it so i figured the syntax was wrong.. but if i need an alias thats that :D

Share this post


Link to post
Share on other sites

×

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.