|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
making http:// clickable
OK, here's my problem at the moment, i've written a basic msg board using php and mySQL, and basically everytime u post to the board, it'll write an entry into the database. Here's my problem. I want to make my message board such that every time someone types:
http://something it'll convert it into: <a href=http://something>something</a> I've tried something along the lines of $result = mysql_query("SELECT * , REPLACE ( comment, 'http://%', '<a href=http://%>http://%</a>' )comment_link FROM db"); but that doesn't work... can anyone please tell me how I'd be able to go about doing it please? thanQ! |
|
#2
|
|||
|
|||
|
Is it a single line field or multiple line?
|
|
#3
|
|||
|
|||
|
ermm... what do you mean? like, I use a text area to input the text, so I guess it's a multipleline field, if that's what you mean?
|
|
#4
|
||||
|
||||
|
What happens if you change http://something to http://something/ or http://something/index.htm (or .php) ? try that, might work...
|
|
#5
|
|||
|
|||
|
hrmm...? I don't really get what you mean nicat23...
|
|
#6
|
|||
|
|||
|
use regular Expressions ..
best regards |
|
#7
|
||||
|
||||
|
In your code, do you have the final forward slash at the end of the url? For example, you said that you have it as
Code:
http://something what happens if you include a final / at the end of something like this Code:
http://something/ |
|
#8
|
|||
|
|||
|
Have you thought to use tags, like these forums use [ url ] and [ /url ] (no spaces),
something like that for a use to define a link, then in php replace every instance of [ url ] with '<a href="' and [ /url ] with '">click here</a>' for example, or do you want it to auto detect URLs without the user specifying that it should be a url? Remember if you auto detect URLs this may not be what the user is expecting, they may prefer to specify urls in some manner, how ever should you wish to detect URLs auto then I would reccomend doing it with with php, not within an SQL command. |
|
#9
|
|||
|
|||
|
THanks Peoples, yeahp I used regular expressions and it's all working now!!!
![]() |
|
#10
|
||||
|
||||
|
I'm curious to see the code you've used... if its not too big, could ya post it here?
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > making http:// clickable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|