473,785 Members | 2,990 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

if i wanted to have the text i enter into a database be retrived formated the way i want it how could i do that

say i want spacing in my text so instead of doing
<br>
<br>
in between the lines
or having to do <href = or <a href = for a link
what could i do to have php enter to mysql or retrive it formated?

Nov 20 '06 #1
13 1559
so many sites so little time wrote:
say i want spacing in my text so instead of doing
<br>
<br>
in between the lines
or having to do <href = or <a href = for a link
what could i do to have php enter to mysql or retrive it formated?
I don't quite understand what you are saying. Could you give an
example of what text you have, and what you want to get out of it?
Nov 20 '06 #2
so many sites so little time wrote:
say i want spacing in my text so instead of doing
<br>
<br>
in between the lines
or having to do <href = or <a href = for a link
what could i do to have php enter to mysql or retrive it formated?
Does this do what you want?
http://us3.php.net/manual/en/function.nl2br.php

It would take care of the line spacing issue, but I don't quite
understand what you want to do with links.

Nov 20 '06 #3
<comp.lang.ph p>
<so many sites so little time>
<19 Nov 2006 21:17:23 -0800>
<11************ **********@k70g 2000cwa.googleg roups.com>
say i want spacing in my text so instead of doing
<br>
<br>
in between the lines
or having to do <href = or <a href = for a link
what could i do to have php enter to mysql or retrive it formated?
If you mean you have a piece of bare text like http://www.whatever.com
and you want to make it into a hyperlink after grabbing it from your
database - then you could do something like the following .

<?php

$grab="http://www.whatever.co m";

$extra="<a href=$grab>$gra b</a>";

print $extra;

?>

You could then store $extra in your database so it could be grabbed and
displayed like the following .

<?php

# read $extra from database .

print $extra;

?>
--
www.phpwhois.co.uk
Nov 20 '06 #4
Message-ID: <MP************ ************@ne ws.newsreader.c omfrom
Krustov contained the following:
>or having to do <href = or <a href = for a link
what could i do to have php enter to mysql or retrive it formated?

If you mean you have a piece of bare text like http://www.whatever.com
and you want to make it into a hyperlink after grabbing it from your
database - then you could do something like the following .

<?php

$grab="http://www.whatever.co m";

$extra="<a href=$grab>$gra b</a>";

print $extra;

?>
It could be that he wants to turn anything that just looks like a link
into a link. That would involve a bit of regex (note to self: must put
in effort to learn more regex...)

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Nov 20 '06 #5
yeah i guess i should get into regex, basicly i should prob just make a
button like most message boards do out of javascript to let them make
it a link i think wordpress does it that way to... blah off to school
Geoff Berrow wrote:
Message-ID: <MP************ ************@ne ws.newsreader.c omfrom
Krustov contained the following:
or having to do <href = or <a href = for a link
what could i do to have php enter to mysql or retrive it formated?
If you mean you have a piece of bare text like http://www.whatever.com
and you want to make it into a hyperlink after grabbing it from your
database - then you could do something like the following .

<?php

$grab="http://www.whatever.co m";

$extra="<a href=$grab>$gra b</a>";

print $extra;

?>

It could be that he wants to turn anything that just looks like a link
into a link. That would involve a bit of regex (note to self: must put
in effort to learn more regex...)

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Nov 20 '06 #6
acutally what krustov said is more of what i want, as long as they
write out the link http:// then it should work well.
so many sites so little time wrote:
yeah i guess i should get into regex, basicly i should prob just make a
button like most message boards do out of javascript to let them make
it a link i think wordpress does it that way to... blah off to school
Geoff Berrow wrote:
Message-ID: <MP************ ************@ne ws.newsreader.c omfrom
Krustov contained the following:
>or having to do <href = or <a href = for a link
>what could i do to have php enter to mysql or retrive it formated?
>>
>
>If you mean you have a piece of bare text like http://www.whatever.com
>and you want to make it into a hyperlink after grabbing it from your
>database - then you could do something like the following .
>
><?php
>
>$grab="http://www.whatever.co m";
>
>$extra="<a href=$grab>$gra b</a>";
>
>print $extra;
>
>?>
It could be that he wants to turn anything that just looks like a link
into a link. That would involve a bit of regex (note to self: must put
in effort to learn more regex...)

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Nov 20 '06 #7
so many sites so little time wrote:
acutally what krustov said is more of what i want, as long as they
write out the link http:// then it should work well.
so many sites so little time wrote:
yeah i guess i should get into regex, basicly i should prob just make a
button like most message boards do out of javascript to let them make
it a link i think wordpress does it that way to... blah off to school
Geoff Berrow wrote:
Message-ID: <MP************ ************@ne ws.newsreader.c omfrom
Krustov contained the following:
>
or having to do <href = or <a href = for a link
what could i do to have php enter to mysql or retrive it formated?
>

If you mean you have a piece of bare text like http://www.whatever.com
and you want to make it into a hyperlink after grabbing it from your
database - then you could do something like the following .

<?php

$grab="http://www.whatever.co m";

$extra="<a href=$grab>$gra b</a>";

print $extra;

?>
>
It could be that he wants to turn anything that just looks like a link
into a link. That would involve a bit of regex (note to self: must put
in effort to learn more regex...)
>
>
>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/


If you want to search plain text for valid urls and replace them with
links, here is a regex that may help you out:
<?php
$rx = '
{
\b
# Match the leading part (proto://hostname, or just hostname)
(
# ftp://, http://, or https:// leading part
(ftp|https?)://[-\w]+(\.\w[-\w]*)+
|
# or, try to find a hostname with our more specific
sub-expression
(?i: [a-z0-9] (?:[-a-z0-9]*[a-z0-9])? \. )+ # sub domains
# Now ending .com, etc. For these, require lowercase
(?-i: com\b
| edu\b
| biz\b
| gov\b
| in(?:t|fo)\b # .int or .info
| mil\b
| net\b
| org\b
| [a-z][a-z]\b # two-letter country codes
)
)

# Allow an optional port number
( : \d+ )?

# The rest of the URL is optional, and begins with / . . .
(

/
# The rest are heuristics for what seems to work well
[^;"\'<>()\[\]{}\s\x7F-\xFF]*
(?:
[.,?]+ [^;"\'<>()\[\]{}\s\x7F-\xFF]+
)*
)?
}x';

$text = "blah blah http://www.google.com, text text more text etc";
echo preg_replace ($rx, '<a href="\1">\1</a>', $text);
?>

Nov 21 '06 #8
so many sites so little time wrote:
acutally what krustov said is more of what i want, as long as they
write out the link http:// then it should work well.
so many sites so little time wrote:
yeah i guess i should get into regex, basicly i should prob just make a
button like most message boards do out of javascript to let them make
it a link i think wordpress does it that way to... blah off to school
Geoff Berrow wrote:
Message-ID: <MP************ ************@ne ws.newsreader.c omfrom
Krustov contained the following:
>
or having to do <href = or <a href = for a link
what could i do to have php enter to mysql or retrive it formated?
>

If you mean you have a piece of bare text like http://www.whatever.com
and you want to make it into a hyperlink after grabbing it from your
database - then you could do something like the following .

<?php

$grab="http://www.whatever.co m";

$extra="<a href=$grab>$gra b</a>";

print $extra;

?>
>
It could be that he wants to turn anything that just looks like a link
into a link. That would involve a bit of regex (note to self: must put
in effort to learn more regex...)
>
>
>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/


If you want to search plain text for valid urls and replace them with
links, here is a regex that may help you out:
<?php
$rx = '
{
\b
# Match the leading part (proto://hostname, or just hostname)
(
# ftp://, http://, or https:// leading part
(ftp|https?)://[-\w]+(\.\w[-\w]*)+
|
# or, try to find a hostname with our more specific
sub-expression
(?i: [a-z0-9] (?:[-a-z0-9]*[a-z0-9])? \. )+ # sub domains
# Now ending .com, etc. For these, require lowercase
(?-i: com\b
| edu\b
| biz\b
| gov\b
| in(?:t|fo)\b # .int or .info
| mil\b
| net\b
| org\b
| [a-z][a-z]\b # two-letter country codes
)
)

# Allow an optional port number
( : \d+ )?

# The rest of the URL is optional, and begins with / . . .
(

/
# The rest are heuristics for what seems to work well
[^;"\'<>()\[\]{}\s\x7F-\xFF]*
(?:
[.,?]+ [^;"\'<>()\[\]{}\s\x7F-\xFF]+
)*
)?
}x';

$text = "blah blah http://www.google.com, text text more text etc";
echo preg_replace ($rx, '<a href="\1">\1</a>', $text);
?>

Nov 21 '06 #9
Of course, that was from "Mastering Regular Expressions, 2nd Edition",
by Jeffrey E. F. Friedl. It's a great book - definitely a must-read.

Nov 21 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1446
by: Nuno Paquete | last post by:
Hi group. I need to post text to a PHP page for introducing that text to a database. Is there any function that convert my text into HTML before introduce it in the database? I need this for introducing comments directly from <TEXTAREA> HTML' objects to a database, and get it formated when I show it latter in normal HTML files. For example, if I press ENTER key then I need to represent this new line when some one see the comments latter,...
8
6448
by: Beznas | last post by:
Hi All; I'm trying to create an ASP function called CleanX that removes the punctuation and some characters like (*&^%$#@!<>?"}|{..) from a text string I came up with this but It doesn't look like it's working. Can anyone help please. THANK YOU.
0
1190
by: Ruby | last post by:
Hi,All I face a problem when i enter a simple text in the existing formated RitchTextBox Control. There is a problem is that i can't enter a simple text in a specific place, it may be after a word or after a reagion that i will fixed. In runtime the text will placed in this fixed place without changing the format of the existing text. If anyone know the solution plz help me. thanx..
3
5378
by: sb Luis | last post by:
I Use the following code to read from MS Word, but I couldent read Formated Text (RTF). How Can I read formated text from MS Word Doc without using clipboard. thanks. Word.ApplicationClass WordApp = new Word.ApplicationClass(); ..... // Let's get the content from the document Word.Paragraphs DocPar = Doc.Paragraphs; // Count number of paragraphs in the file
2
8011
by: Ted Ngo | last post by:
Hi All, I did create a dropdownbox and populate the data from the database. I want the user able to enter the text or select data from the dropdownlist box. When the user enter the text and if it match the data in the dropdownlist box then those data will display. I want to do something like, in the IE, where the user enter the world wide web Address.
11
22547
by: vivekgrs | last post by:
hi my requirement is read the data from the text file through vb. then calculate the data and write the result on the same text file where the data has retrived thru vb 6.0. how 2 implement the namespace in vb 6.0 i had read the text file by using Dim sfil As String Dim dd Dim schunk As String Dim nSourceFile As Integer, sText As String sfil = "E:\proposed.txt"
4
3529
Sheepman
by: Sheepman | last post by:
My quest, to put 100 random numbers in ten rows of ten. Then output the same to the screen and a file. My screen output is working,yeah! Text file, not so much. The data is getting there but not formated. If word wrap is off it's a single row. If word wraps on, well ... it wraps. I've considered sizing the notebook window to wrap at the tenth character but I don't think the TA working on his Phd will buy it. Help please! My code for this portion...
7
1840
by: nandithadevaraj | last post by:
Hai All, Please help me on this How to Update the Data which is present in the textboxes, the data is retrived from the database to textboxes, Just i want to modify and to update in the Database i am trying this in C# language please help me out Thank u
5
1716
by: insomnia | last post by:
Hi there a quick simple question, i need to be able to validate a textbox The user must enter a number within the range 0001 to 9999 only. And in the 4 number format XXXX , e.g. if they enter the number 11 i need it to be formated 0011. thanks
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10151
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.