Re: converting text to hypertext

2003-01-13 Thread Michael T. Babcock
Rodney Broom wrote:


If so, then the answer is that there isn't such a data type. If you want a link, then you'll have to make it yourself. I suggest making your column a varchar(). Then, you ~might~ get the data with a query like this:

 SELECT CONCAT(CONCAT('a href=', link, ''), link, '/a') FROM stuff;
 


But please remember, as was said earlier, to use the appropriate 
escaping functions for your language to make sure link contains no 
special HTML characters in the second instance and no URL characters in 
the first.

--
Michael T. Babcock
C.T.O., FibreSpeed Ltd.
http://www.fibrespeed.net/~mbabcock




-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Re: converting text to hypertext

2003-01-09 Thread Michael T. Babcock
Rick Tucker wrote:


This is the code I'm using.  I'm pretty new to PHP, so there may be a simple
solution within PHP of which I'm unaware.  I just thought it could be done
from the MySQL side of things.



I think the point is more that there's no reason to have MySQL do it at 
all since the logic is specific to what you're doing.

$resultID = mysql_query(SELECT * FROM ports, $linkID);

print tabletrthPort #/th;
print thTransport/thth align=centerApplication/thth
align=centerRFC/Vendor's URL/MS KB article/th;

while ($row = mysql_fetch_row($resultID))
{
print tr;
foreach ($row as $field)
{
print td align=center$field/td;
}
print /tr;
}
print /table;
mysql_close ($linkID);
 


If these fields are intended to be URIs, try something like (I didn't 
check my PHP function names; look them up first):

function LinkURI($URI)
{
   $HREF = urlencode($URI);
   $Text = htmlentities($URI);
   return a href=\$HREF\$Text/a;
}

print td align=center.LinkURI($field)./td;

--
Michael T. Babcock
C.T.O., FibreSpeed Ltd.
http://www.fibrespeed.net/~mbabcock



-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Re: converting text to hypertext

2003-01-08 Thread Paul DuBois
At 8:34 -0800 1/8/03, Rick Tucker wrote:

I just imported a .csv file and one of the columns of data was websites
addresses.  Those addresses aren't being recognized as links when I output
an html table from my queries.  I'm scratching me head on how to make the
conversion.  I figured there would by a hypertext datatype of some sort, but
I can't find any information regarding this issue. If someone could point me
in the right direction, I would appreciate it.


You must perform the conversion yourself, displaying the URL both
as the href atttribute and body text of an a tag.  Don't forget
to URL-encode it for use in the attribute, and HTML-encode it for
use in the body text.

Examples in Perl, PHP, Python, and JSP are available at:

http://www.kitebird.com/mysql-cookbook/

Get the recipes distribution, check the apache/links and tomcat/mcb
directories for the examples.

Mmm, that's two book plugs in a day, I'd better cool off for a while. :-)



Thanks,

rick



-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: converting text to hypertext

2003-01-08 Thread walt
Rick Tucker wrote:

 I just imported a .csv file and one of the columns of data was websites
 addresses.  Those addresses aren't being recognized as links when I output
 an html table from my queries.  I'm scratching me head on how to make the
 conversion.  I figured there would by a hypertext datatype of some sort, but
 I can't find any information regarding this issue. If someone could point me
 in the right direction, I would appreciate it.

 Thanks,

 rick

 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Rick,
Are the addresses appearing in the correct format (http://www.somewhere.com) when
you pull them from the db?
If so,  you'll still have to build the  a href  part in the html so it is
infact a hyperlink.

walt


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: converting text to hypertext

2003-01-08 Thread Rodney Broom
From: Rick Tucker [EMAIL PROTECTED]


 Those addresses aren't being recognized as links when I output
 an html table from my queries.
[ snip ]
 I figured there would by a hypertext datatype of some sort...


Do you mean like this:

  CREATE TABLE stuff (
link hypertext
  );

  INSERT INTO stuff (link) VALUES ('http://www.rbroom.com/');

  SELECT * FROM stuff;
  a href=http://www.rbroom.com/;http://www.rbroom.com//a


If so, then the answer is that there isn't such a data type. If you want a link, then 
you'll have to make it yourself. I suggest making your column a varchar(). Then, you 
~might~ get the data with a query like this:

  SELECT CONCAT(CONCAT('a href=', link, ''), link, '/a') FROM stuff;



---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/

sql



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: converting text to hypertext

2003-01-08 Thread Zak Greant
On Wed, Jan 08, 2003 at 08:34:25AM -0800, Rick Tucker wrote:
 I just imported a .csv file and one of the columns of data was websites
 addresses.  Those addresses aren't being recognized as links when I output
 an html table from my queries.  I'm scratching me head on how to make the
 conversion.  I figured there would by a hypertext datatype of some sort, but
 I can't find any information regarding this issue. If someone could point me
 in the right direction, I would appreciate it.

  Good Day Rick!

  There is no hypertext/hyperlink data type and I do not know of any plans for 
  one.

  A simple bit of shell scripting like:

mysql -e SELECT something FROM somewhere -H |\
sed -e 's/http:\/\/[^ ]\+/a href=\/a/'

  should replace all of the valid http URLs in your HTML tables with anchors.

  Cheers!
-- 
 Zak Greant [EMAIL PROTECTED] | MySQL Advocate |  http://zak.fooassociates.com

Using and Managing MySQL
  MySQL Training: London, January 13-17, 2003
  Visit http://mysql.com/training for more information

While we are postponing, life speeds by.--Lucius Annaeus Seneca

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: converting text to hypertext

2003-01-08 Thread Rick Tucker
Larry,

This is the code I'm using.  I'm pretty new to PHP, so there may be a simple
solution within PHP of which I'm unaware.  I just thought it could be done
from the MySQL side of things.


$resultID = mysql_query(SELECT * FROM ports, $linkID);

print tabletrthPort #/th;
print thTransport/thth align=centerApplication/thth
align=centerRFC/Vendor's URL/MS KB article/th;

while ($row = mysql_fetch_row($resultID))

{
print tr;
foreach ($row as $field)
{
print td align=center$field/td;
}
print /tr;
}
print /table;
mysql_close ($linkID);



Thanks,

rick


-Original Message-
From: Larry Brown [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 10:13 AM
To: Rick Tucker
Subject: RE: converting text to hypertext


The question seems to me how are you outputting to html?

Larry S. Brown
Dimension Networks, Inc.
(727) 723-8388

-Original Message-
From: Rick Tucker [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 11:34 AM
To: [EMAIL PROTECTED]
Subject: converting text to hypertext

I just imported a .csv file and one of the columns of data was websites
addresses.  Those addresses aren't being recognized as links when I output
an html table from my queries.  I'm scratching me head on how to make the
conversion.  I figured there would by a hypertext datatype of some sort, but
I can't find any information regarding this issue. If someone could point me
in the right direction, I would appreciate it.

Thanks,

rick


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: converting text to hypertext

2003-01-08 Thread Larry Brown
Try...

while ($row = mysql_fetch_row($resultID))

{
print tr;
foreach ($row as $field)
{
print td align=centera href=$field$field/a/td;
}
print /tr;
}
print /table;
mysql_close ($linkID);

I don't use print so I'm not sure about that, I use echo.

Larry S. Brown
Dimension Networks, Inc.
(727) 723-8388

-Original Message-
From: Rick Tucker [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 1:58 PM
To: Larry Brown
Cc: [EMAIL PROTECTED]
Subject: RE: converting text to hypertext

Larry,

This is the code I'm using.  I'm pretty new to PHP, so there may be a simple
solution within PHP of which I'm unaware.  I just thought it could be done
from the MySQL side of things.


$resultID = mysql_query(SELECT * FROM ports, $linkID);

print tabletrthPort #/th;
print thTransport/thth align=centerApplication/thth
align=centerRFC/Vendor's URL/MS KB article/th;

while ($row = mysql_fetch_row($resultID))

{
print tr;
foreach ($row as $field)
{
print td align=center$field/td;
}
print /tr;
}
print /table;
mysql_close ($linkID);



Thanks,

rick


-Original Message-
From: Larry Brown [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 10:13 AM
To: Rick Tucker
Subject: RE: converting text to hypertext


The question seems to me how are you outputting to html?

Larry S. Brown
Dimension Networks, Inc.
(727) 723-8388

-Original Message-
From: Rick Tucker [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 11:34 AM
To: [EMAIL PROTECTED]
Subject: converting text to hypertext

I just imported a .csv file and one of the columns of data was websites
addresses.  Those addresses aren't being recognized as links when I output
an html table from my queries.  I'm scratching me head on how to make the
conversion.  I figured there would by a hypertext datatype of some sort, but
I can't find any information regarding this issue. If someone could point me
in the right direction, I would appreciate it.

Thanks,

rick


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: converting text to hypertext

2003-01-08 Thread R. Hannes Niedner
On 1/8/03 8:34 AM, Rick Tucker [EMAIL PROTECTED] wrote:

 I just imported a .csv file and one of the columns of data was websites
 addresses.  Those addresses aren't being recognized as links when I output
 an html table from my queries.  I'm scratching me head on how to make the
 conversion.  I figured there would by a hypertext datatype of some sort, but
 I can't find any information regarding this issue. If someone could point me
 in the right direction, I would appreciate it.
 
 Thanks,
 
 rick

Sorry I was to fast: (mailto: was missing, but you probably figured that by
yourself).

SELECT CONCAT('a href=\mailto:' ,email, '\'', email, '/a') FROM
mytable;

And 'email' is the name of the column that stores your email address.
http://www.mysql.com/doc/en/String_functions.html

Best/h


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: converting text to hypertext

2003-01-08 Thread Bryant Hester
 
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Rick,

How are you pulling the data? PHP? Perl? ASP? HTML doesn't
automatically insert hyperlinks where it finds
http://www.somedomain.com. It has to be told that it is a link by the
A HREF=http://www.somedomain.com;SomeDomain/A 
tag.

If you are pulling via php you could do something along the lines of:
?
While ($row = mysql_fetch_row($result)) {
echo tda href='$row[0]'$row[0]/a\n;
}
?

There is a similar way in ASP  Perl, I'm sure.

HTH,
Bryant H. Hester 

- -Original Message-
From: Rick Tucker [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, January 08, 2003 10:34 AM
To: [EMAIL PROTECTED]
Subject: converting text to hypertext


I just imported a .csv file and one of the columns of data was
websites addresses.  Those addresses aren't being recognized as links
when I output an html table from my queries.  I'm scratching me head
on how to make the conversion.  I figured there would by a hypertext
datatype of some sort, but I can't find any information regarding
this issue. If someone could point me in the right direction, I would
appreciate it.

Thanks,

rick


- -
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try:
http://lists.mysql.com/php/unsubscribe.php


-BEGIN PGP SIGNATURE-
Version: PGPfreeware 7.0.3 for non-commercial use http://www.pgp.com

iQA/AwUBPhyBx0lWu7/HFp4nEQKrSwCfQY25Z+rwm4VOYDnwcyrM/wxwnl4AoNgj
DGgAFbw1Y9Fp7atdT7LNTIl+
=3+NL
-END PGP SIGNATURE-


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: converting text to hypertext

2003-01-08 Thread Keith C. Ivey
On 8 Jan 2003, at 12:08, Paul DuBois wrote:

 You must perform the conversion yourself, displaying the URL both
 as the href atttribute and body text of an a tag.  Don't forget
 to URL-encode it for use in the attribute, and HTML-encode it for
 use in the body text.

I think Paul meant to say you should HTML-encode it for both the HREF 
value and the link text.  URL-encoding is for *parameters* that are 
going to become part of a URL.  You wouldn't URL-encode a whole URL 
(unless you were passing it as a parameter in another URL -- perhaps 
the URL of a redirection script).  A URL-encoded URL wouldn't work as 
a link, since the slashes would have been changed to '%2F', among 
other things.

The HTML-encoding is only necessary if the URL could contain an 
ampersand (or less-than, greater-than, or quote, but URLs aren't 
supposed to have those characters in them).

[Filter fodder: SQL]

-- 
Keith C. Ivey [EMAIL PROTECTED]
Tobacco Documents Online
http://tobaccodocuments.org
Phone 202-667-6653

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: converting text to hypertext

2003-01-08 Thread wcb
 Hi Rick!

You could also do something like the following (I'm assuming that the
http://www part isn't in $field already. . .).

=
print tr;
 foreach ($row as $field)
 {
 print td align=centera
href=http://www.$field/;http://www.$field/td;
 }
 print /tr;
=

Cheers!

-warren



for filter: query, mysql, bigint


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: converting text to hypertext

2003-01-08 Thread Jennifer Goodie
HTML doesn't just see a URL and automatically make it a hyperlink it is not
helpful like MS products.  So what you are seeing is expected behavior.  I
would alter the while loop to look like this...


while ($row = mysql_fetch_array($resultID)){ #fetch_array adds little
overhead and gives you an associative array that is easy to work with
print tr\n\ttd$row[Port]/td\n\ttd$row[Application]/td\n\ttda
href='$row[URL]' target='_blank'$row[URL]/a/td\n/tr\n;
}

I do not know your column names and have assumed they are Port,Application,
and URL.  I am probably wrong, put your column names in their place.  By
selecting * and just looping through the fields returned you are relying on
them being returned in a certain order, while that will work, it is bad
practice.  It also made the code confusing and hard to read and didn't
really save you any typing.  This is just a quick solution, I did not check
the html or debug the code or look for security flaws, or put logic in place
for poorly formed URLs, you should be able to handle that.




-Original Message-
From: Rick Tucker [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 10:58 AM
To: Larry Brown
Cc: [EMAIL PROTECTED]
Subject: RE: converting text to hypertext


Larry,

This is the code I'm using.  I'm pretty new to PHP, so there may be a simple
solution within PHP of which I'm unaware.  I just thought it could be done
from the MySQL side of things.


$resultID = mysql_query(SELECT * FROM ports, $linkID);

print tabletrthPort #/th;
print thTransport/thth align=centerApplication/thth
align=centerRFC/Vendor's URL/MS KB article/th;

while ($row = mysql_fetch_row($resultID))

{
print tr;
foreach ($row as $field)
{
print td align=center$field/td;
}
print /tr;
}
print /table;
mysql_close ($linkID);



Thanks,

rick


-Original Message-
From: Larry Brown [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 10:13 AM
To: Rick Tucker
Subject: RE: converting text to hypertext


The question seems to me how are you outputting to html?

Larry S. Brown
Dimension Networks, Inc.
(727) 723-8388

-Original Message-
From: Rick Tucker [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 11:34 AM
To: [EMAIL PROTECTED]
Subject: converting text to hypertext

I just imported a .csv file and one of the columns of data was websites
addresses.  Those addresses aren't being recognized as links when I output
an html table from my queries.  I'm scratching me head on how to make the
conversion.  I figured there would by a hypertext datatype of some sort, but
I can't find any information regarding this issue. If someone could point me
in the right direction, I would appreciate it.

Thanks,

rick


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: converting text to hypertext

2003-01-08 Thread R. Hannes Niedner
On 1/8/03 8:34 AM, Rick Tucker [EMAIL PROTECTED] wrote:

 I just imported a .csv file and one of the columns of data was websites
 addresses.  Those addresses aren't being recognized as links when I output
 an html table from my queries.  I'm scratching me head on how to make the
 conversion.  I figured there would by a hypertext datatype of some sort, but
 I can't find any information regarding this issue. If someone could point me
 in the right direction, I would appreciate it.
 
 Thanks,
 
 rick

How about :

a href=mailto:[EMAIL PROTECTED];[EMAIL PROTECTED]/a

Thus if you just store:
[EMAIL PROTECTED]
in your database then you need to retrieve it with the CONCAT function

SELECT CONCAT('a href=\' ,email, '\'', email, '/a') FROM mytable;

And 'email' is the name of the column that stores your email address.
http://www.mysql.com/doc/en/String_functions.html

Best/h


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: converting text to hypertext

2003-01-08 Thread Paul DuBois
At 17:23 -0500 1/8/03, Keith C. Ivey wrote:

On 8 Jan 2003, at 12:08, Paul DuBois wrote:


 You must perform the conversion yourself, displaying the URL both
 as the href atttribute and body text of an a tag.  Don't forget
 to URL-encode it for use in the attribute, and HTML-encode it for
 use in the body text.


I think Paul meant to say you should HTML-encode it for both the HREF
value and the link text.  URL-encoding is for *parameters* that are
going to become part of a URL.  You wouldn't URL-encode a whole URL
(unless you were passing it as a parameter in another URL -- perhaps
the URL of a redirection script).  A URL-encoded URL wouldn't work as
a link, since the slashes would have been changed to '%2F', among
other things.


Correct, thanks.



The HTML-encoding is only necessary if the URL could contain an
ampersand (or less-than, greater-than, or quote, but URLs aren't
supposed to have those characters in them).

[Filter fodder: SQL]

--
Keith C. Ivey [EMAIL PROTECTED]
Tobacco Documents Online
http://tobaccodocuments.org
Phone 202-667-6653



-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php