RE: [PHP-DB] HTML or PHP?
| From: | Matthew Loff | Date: | Wed, 03 Oct 2001 06:23:45 +0000 |
| Subject: | RE: [PHP-DB] HTML or PHP? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-12955@lists.php.net to get a copy of this message | ||
Without spaces, the URL won't line break...
I recommend one of two things...
1) Use a for() or while() loop with substr(), to print out, say, 50
characters per line, then break to the next line, until reaching the end
of the string...
2) Use an ellipsis ("...") to cut out the middle of the URL if it's too
long... Example:
echo "<A HREF=\"$url\">". (strlen($url) > 50? substr($url, 0,
20)."...".substr($url, -20) : $url) ."</A>\n";
That will shorten:
<A
HREF="http://www.somewhere.com/long/url/goes/here/blah/blah/blah/">http:
//www.somewhere.com/long/url/goes/here/blah/blah/blah/</A>
To something like:
<A
HREF="http://www.somewhere.com/long/url/goes/here/blah/blah/blah/">http:
//www.somewhere...here/blah/blah/blah/</A>
If you wanted more accurate simplifying of URL displays with an
ellipsis, you could explode() the URL, using the slash '/' as the
delimeter... But that's a bit more complicated to implement from that
point on... Doing it that way, you could turn:
<A
HREF="http://www.somewhere.com/long/url/goes/here/blah/blah/blah/">http:
//www.somewhere.com/long/url/goes/here/blah/blah/blah/</A>
Into:
<A
HREF="http://www.somewhere.com/long/url/goes/here/blah/blah/blah/">http:
//www.somewhere.com/.../blah/</A>
Good luck with whatever method you choose.
--Matt
-----Original Message-----
From: Dobromir Velev [mailto:diadomraz@rambler.bg]
Sent: Wednesday, October 03, 2001 2:13 AM
To: Jason Caldwell; php-db@lists.php.net
Subject: Re: [PHP-DB] HTML or PHP?
Hi,
Just set the width of the cell the URL is placed in.
Something like
<tr><td width='300'>$url</td><td
width='300'>...</td></tr>
HTH
Dobromir Velev
-----Original Message-----
From: Jason Caldwell <jason@thinkingman.org>
To: php-db@lists.php.net <php-db@lists.php.net>
Date: Wednesday, October 03, 2001 2:20 AM
Subject: [PHP-DB] HTML or PHP?
>I have a problem that seems like it should be a snap to fix, but leaves
>me feeling frustrated to no end...
>
>I have a table (HTML) -- 2 Columns. In the right-hand column I store a
>URL (ie.
>http://someonesdomainname.com/path/anotherpath/file.html)
>
>The problem is -- when I pull the URL in -- it *pushes* my columns
>around and expands my table beyond the page -- I have my table hard set
>at 600 pixels (not 100%) --
>
>How can I force the URL (or any text for that matter that doesn't have
>spaces in it) -- to *wrap*?? Can I do this with HTML (I hope) or do I
>need to write some PHP code to force break the string into workable
>sections?
>
>Thanks.
>jason@thinkingman.org
>
>
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
>For additional commands, e-mail: php-db-help@lists.php.net
>To contact the list administrators, e-mail:
>php-list-admin@lists.php.net
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net