dachshund Posted May 2, 2009 Share Posted May 2, 2009 hi sorry if this doesn't make much sense, but it's quite hard to describe. is there a way of limiting the amount of text that your php code can input into a table? for example if in the mysql table field there is 150 characters of text, but i only want it to recall a maximum of 80 characters. is there a way of doing this? hope that makes sense, it's quite late and i'm pretty tired. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 $str = 'something...'; $len = 80; if (($str_len = strlen($str)) < $len) $len = $str_len; $str = substr($str, 0, $len); Quote Link to comment Share on other sites More sharing options...
dachshund Posted May 3, 2009 Author Share Posted May 3, 2009 what should i put in the place of '...something'? sorry for my ignorance Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 Whatever string you got back from the DB. Quote Link to comment Share on other sites More sharing options...
dachshund Posted May 3, 2009 Author Share Posted May 3, 2009 hmm can't get it to work here's parts of my code. <?php $today = date('Y-m-d'); $sql="SELECT * FROM features ORDER BY id DESC"; $result=mysql_query($sql); $str = 'something...'; $len = 80; if (($str_len = strlen($str)) < $len) $len = $str_len; $str = substr($str, 0, $len); ?> and this is the echo i want to limit <? echo $rows['condensedcontent']; ?> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 Then set $str to that. Think people! I'm sorry life's not easy. Quote Link to comment Share on other sites More sharing options...
dachshund Posted May 3, 2009 Author Share Posted May 3, 2009 a little more help...? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 a little more help...? Sure! Learn PHP. Quote Link to comment Share on other sites More sharing options...
dachshund Posted May 3, 2009 Author Share Posted May 3, 2009 if only there was a forum where people could teach me...haha Quote Link to comment Share on other sites More sharing options...
Axeia Posted May 3, 2009 Share Posted May 3, 2009 Could let the database do the work. SELECT SUBSTR(id,0,20) from features ORDER BY id DESC (assuming id is the only colum) Quote Link to comment Share on other sites More sharing options...
dachshund Posted June 4, 2009 Author Share Posted June 4, 2009 hi, would any one be able to help me out a bit more with this? still can't get it to work. would be much appreciated. Quote Link to comment Share on other sites More sharing options...
dachshund Posted June 5, 2009 Author Share Posted June 5, 2009 no? no one? Quote Link to comment 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.