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? Link to comment https://forums.phpfreaks.com/topic/91652-reducing-the-length-of-a-database-output/ 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); Link to comment https://forums.phpfreaks.com/topic/91652-reducing-the-length-of-a-database-output/#findComment-469398 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. Link to comment https://forums.phpfreaks.com/topic/91652-reducing-the-length-of-a-database-output/#findComment-469400 Share on other sites More sharing options...
vicodin Posted February 18, 2008 Share Posted February 18, 2008 Had to show me up didnt you Link to comment https://forums.phpfreaks.com/topic/91652-reducing-the-length-of-a-database-output/#findComment-469403 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); Link to comment https://forums.phpfreaks.com/topic/91652-reducing-the-length-of-a-database-output/#findComment-469416 Share on other sites More sharing options...
jonoc33 Posted February 18, 2008 Author Share Posted February 18, 2008 That worked. Thanks Link to comment https://forums.phpfreaks.com/topic/91652-reducing-the-length-of-a-database-output/#findComment-469420 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.