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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.