Printing off the page....

Printing off the page....

am 13.05.2005 11:55:12 von SG Edwards

Hi guys,

I have a postgres database connected to a website using PHP.
I have a table that stores gene sequences which are very long (approx. 80=
0
characters).

If I try and print this, it prints as a single line which runs off the pa=
ge. Is
there a way to print the sequence with a line break every 50 characters?

for example,

AAAAAAAAAAAACCCCCCCCCCC
TTTTTTTTTTTTTTTTGGGGGGG
AAAAAAAAATTT


Rather than:

AAAAAAAAAAACCCCCCCCCCCCTTTTTTTTTTTTTGGGGGGGGGGGAAAAAAAAAATTT

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Re: Printing off the page....

am 13.05.2005 13:49:03 von David Blanco

Hi!

2005/5/13, SG Edwards :
>=20
> Hi guys,
>=20
> 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).
>=20
> If I try and print this, it prints as a single line which runs off the pa=
ge. Is
> there a way to print the sequence with a line break every 50 characters?

This seems to be a PHP question, not about PHP-Posgresql :-)

If I understood you right, you can do it with the PHP function "substr"

http://php.net/substr

It's easy to iterate throug the string and to intercalate the line
breaks wherever you want

Bye

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Re: Printing off the page....

am 13.05.2005 13:58:50 von Volkan YAZICI

Hi,

On 5/13/05, SG Edwards 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).
>=20
> If I try and print this, it prints as a single line which runs off the pa=
ge. Is
> there a way to print the sequence with a line break every 50 characters?
>=20
> for example,
>=20
> AAAAAAAAAAAACCCCCCCCCCC
> TTTTTTTTTTTTTTTTGGGGGGG
> AAAAAAAAATTT
>=20
> Rather than:
> AAAAAAAAAAACCCCCCCCCCCCTTTTTTTTTTTTTGGGGGGGGGGGAAAAAAAAAATTT

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

function wrapAndPrint($text, $maxLineLen =3D 50)
{
// We don't need to make a strlen() call everytime.
$lineLen =3D strlen($text);

for ( $i =3D 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.

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Re: Printing off the page....

am 13.05.2005 14:03:57 von Volkan YAZICI

Oops. I forgot some other built-in PHP functions.

I think it's more feasible to use chunk_split(). (You can take a look
at wordwrap() function too but I'd advice chunk_split(). Also
chunk_split() should work much faster than any other function we wrote
by using PHP.)

Regards.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Re: Printing off the page....

am 14.05.2005 11:02:01 von Christopher Kings-Lynne

Use the PHP wordwrap() function.

SG Edwards wrote:
> Hi guys,
>
> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend