473,503 Members | 2,165 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 1536
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.php>
<so many sites so little time>
<19 Nov 2006 21:17:23 -0800>
<11**********************@k70g2000cwa.googlegroups .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.com";

$extra="<a href=$grab>$grab</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************************@news.newsreader.comfro m
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.com";

$extra="<a href=$grab>$grab</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************************@news.newsreader.comfro m
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.com";

$extra="<a href=$grab>$grab</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************************@news.newsreader.comfro m
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.com";
>
>$extra="<a href=$grab>$grab</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************************@news.newsreader.comfro m
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.com";

$extra="<a href=$grab>$grab</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************************@news.newsreader.comfro m
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.com";

$extra="<a href=$grab>$grab</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
ok wow im most def. gonna use that and tweak it a bit what i really
well what my freind told me i need to figure out is on a message board
the whole bb code i guess it is where you have the buttons above the
textbox and you click bold and it inserts a bold <b></bwhere you are
typing or before the word and after the word if highllighted there must
be some scripts online or i think its gotto be javascript i dunno if i
knew what lang it was it wouldnt be so hard, you know what im talking
about right its got the little chainlink for if you want a link and
stuff like that
malatestapunk wrote:
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 #11
one last quick thing can i have lets say $text be something like $a =
$b & $c
malatestapunk wrote:
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 #12
like can one var = 2 others
so many sites so little time wrote:
one last quick thing can i have lets say $text be something like $a =
$b & $c
malatestapunk wrote:
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 #13

so many sites so little time wrote:
like can one var = 2 others
so many sites so little time wrote:
one last quick thing can i have lets say $text be something like $a =
$b & $c
malatestapunk wrote:
Of course, that was from "Mastering Regular Expressions, 2nd Edition",
by Jeffrey E. F. Friedl. It's a great book - definitely a must-read.
I'm not sure I understand - but if jou just want to concatenate two
strings (append one string to the other one), you can do it like this:

$s1 = "bla"; $s2 = "a string";
echo $s1 . $s2; // output: blaa string
// OR
echo "$s1 $s2" // Note: only double quotes here. Output: bla a string

As for the BBCode - it is a specific markup language, where you put
tags in square brackets (as in '...' for bold, etc) - just like
you have in some forums. It's not HTML. There are ready-made PHP
libraries for conversion of BBCode to HTML - check out PHPClasses, for
example. I guess there are some javascript editors (like the one you
described), but I don't have any experience with them.

There are also some javascript HTML editors, and you can use them
instead of BBCode to get HTML right away (note: you really should do
some xss filtering). I kind of like TinyMC Editor
(http://tinymce.moxiecode.com/), some others prefer FCKEditor
(http://www.fckeditor.net/). There are some others too, so you may want
to do some googling.

But if you consider BBCode, you may also want to look at some other
(IMHO, better) markup alternatives - Textile
(http://jimandlissa.com/project/textilephp) and Markdown
(http://www.michelf.com/projects/php-markdown/). They both have syntax
similar to the one used in Wikis (eg. *bold* for bold, etc), and they
both produce valid (x)HTML. It's basically the same approach as with
BBCode (your users input something that's not HTML, but you use some
PHP code to convert that input into valid HTML), but it's easier to
type and read. No ready-made javascript editors (that I know of) for
these, though.

Nov 22 '06 #14

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

Similar topics

1
1425
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...
8
6415
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...
0
1169
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...
3
5347
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...
2
7997
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...
11
22523
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...
4
3511
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...
7
1813
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...
5
1703
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...
0
7093
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...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7353
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...
0
5596
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,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3180
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...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
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 ...
0
401
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...

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.