Jump to content

Reducing the Length of a Database Output


jonoc33

Recommended Posts

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

<?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.

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);

 

 

Archived

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

×
×
  • Create New...

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.