pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Volkan YAZICI <volkan.yazici@gmail.com>
To: SG Edwards <s0460205@sms.ed.ac.uk>
Cc: pgsql-php@postgresql.org
Subject: Re: Printing off the page....
Date: Fri, 13 May 2005 14:58:50 +0300
Message-ID: <7104a73705051304583d38f3ee@mail.gmail.com> (raw)
In-Reply-To: <1115978112.428479801cb7b@sms.ed.ac.uk>
References: <1115978112.428479801cb7b@sms.ed.ac.uk>

Hi,

On 5/13/05, SG Edwards <s0460205@sms.ed.ac.uk> wrote:
> I have a postgres database connected to a website using PHP.
> I have a table that stores gene sequences which are very long (approx. 800
> characters).
> 
> If I try and print this, it prints as a single line which runs off the page. Is
> there a way to print the sequence with a line break every 50 characters?
> 
> for example,
> 
> AAAAAAAAAAAACCCCCCCCCCC
> TTTTTTTTTTTTTTTTGGGGGGG
> AAAAAAAAATTT
> 
> Rather than:
> AAAAAAAAAAACCCCCCCCCCCCTTTTTTTTTTTTTGGGGGGGGGGGAAAAAAAAAATTT

You can write a simple wrap function for it. For example:

function wrapAndPrint($text, $maxLineLen = 50)
{
    // We don't need to make a strlen() call everytime.
    $lineLen = strlen($text);
    
    for ( $i = 0; $i < $lineLen; $i++ )
        print $text[$i].(( $i % $maxLineLen == 0 ) ? '\n' : '');
}

And then you can call wrapAndPrint() function everytime, when you need
to print fetched rows from the query result.

(Also it's possible to write a PL/WHATEVER function for it too.)

Regards.



view thread (5+ messages)  latest in thread

Message-ID: <7104a73705051304583d38f3ee@mail.gmail.com>
Permalink:  ../7104a73705051304583d38f3ee@mail.gmail.com/
Also on:    postgresql.org/message-id/7104a73705051304583d38f3ee@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: volkan.yazici@gmail.com, s0460205@sms.ed.ac.uk
  Subject: Re: Printing off the page....
  In-Reply-To: <7104a73705051304583d38f3ee@mail.gmail.com>
  References: <1115978112.428479801cb7b@sms.ed.ac.uk> <7104a73705051304583d38f3ee@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox