chico1st Posted August 18, 2006 Share Posted August 18, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/17908-solved-only-print-some-of-an-entry/ Share on other sites More sharing options...
fenway Posted August 18, 2006 Share Posted August 18, 2006 1. LEFT( yourColumn, 100 )2. LENGTH( yourColumn) Quote Link to comment https://forums.phpfreaks.com/topic/17908-solved-only-print-some-of-an-entry/#findComment-76819 Share on other sites More sharing options...
chico1st Posted August 20, 2006 Author Share Posted August 20, 2006 these dont seem to work for me... and i cant find them in the either the php or mysql manualsif im supposed to write them how do i take out one character of a string? Quote Link to comment https://forums.phpfreaks.com/topic/17908-solved-only-print-some-of-an-entry/#findComment-77646 Share on other sites More sharing options...
AndyB Posted August 20, 2006 Share Posted August 20, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/17908-solved-only-print-some-of-an-entry/#findComment-77660 Share on other sites More sharing options...
fenway Posted August 20, 2006 Share Posted August 20, 2006 MySQL has an equivalent set of string functions as well, depending on what exactly it is that you're doing in the end. Quote Link to comment https://forums.phpfreaks.com/topic/17908-solved-only-print-some-of-an-entry/#findComment-77665 Share on other sites More sharing options...
chico1st Posted August 20, 2006 Author Share Posted August 20, 2006 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 nothinghttp://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 Quote Link to comment https://forums.phpfreaks.com/topic/17908-solved-only-print-some-of-an-entry/#findComment-77672 Share on other sites More sharing options...
fenway Posted August 21, 2006 Share Posted August 21, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/17908-solved-only-print-some-of-an-entry/#findComment-78170 Share on other sites More sharing options...
chico1st Posted August 22, 2006 Author Share Posted August 22, 2006 well i couldnt get a result from it so i figured the syntax was wrong.. but if i need an alias thats that :D Quote Link to comment https://forums.phpfreaks.com/topic/17908-solved-only-print-some-of-an-entry/#findComment-78428 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.