jonoc33 Posted February 18, 2008 Share Posted February 18, 2008 Hello, I know this is a pretty dumb question, but how exactly would I reduce the output of a record from a database. Say for example I have a record that has about 6000 characters. This is outputted, but I want to reduce that output to about 1000. How would I go about doing this? Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 18, 2008 Share Posted February 18, 2008 This will take off the last 1000 Characters $CutDataFromDb = substr($DataFromDB, 0, -1000); Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted February 18, 2008 Author Share Posted February 18, 2008 <?php if(strlen($row['gnews'] > 2000)){ $gnewssub = substr($row['gnews'], 0, -1000); $gnews = $gnewssub."...<a style='color: #000000;' href='index.php?page=gnews_view&id=".$row['id']."'>More</a>" } else{ $gnews = $row['gnews']; } ?> I tried that, and it still outputs the full thing. Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 18, 2008 Share Posted February 18, 2008 Had to show me up didnt you Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 18, 2008 Share Posted February 18, 2008 I tried it and it worked for me... I think i read your post wrong... So what its gonna do is take off the last 1,000 character. Im pretty sure if you put it this way it should only display the first 1,000 chracters. $CutDataFromDb = substr($DataFromDB, 0, 1000); Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted February 18, 2008 Author Share Posted February 18, 2008 That worked. Thanks 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.