GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Jan-2004, 14:15
giobbi giobbi is offline
New Member
 
Join Date: Jan 2004
Posts: 14
giobbi is on a distinguished road

Klickable web-urls from database.


Im trying to make my weburls/emails klickable but i cant figure out how to. Would love to have some help, see my .php-file here;

<?php
$conn = mysql_connect("localhost", "root", "xxx");

mysql_select_db("receptionen",$conn);

$sql = "select * from emosms";

$result = mysql_query($sql, $conn) or die(mysql_error());

while ($newArray = mysql_fetch_array($result)) {

$namn = $newArray['namn'];

$mobil = $newArray['mobil'];

echo "$namn $mobil<br>";

}

?>

Where and exactly how do i put my <a href....?

Many thanks.
  #2  
Old 22-Jan-2004, 14:30
basdog22 basdog22 is offline
New Member
 
Join Date: Jan 2004
Posts: 14
basdog22 is on a distinguished road
suppose $namn as url:

echo "<a href=\"$namn\" title=\"$namn URL\">$mobil</a>";

  #3  
Old 22-Jan-2004, 14:44
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Hello giobbi,

Paste a sample of the data you are going to have to work with. If you have URLs or Emails included in a block of text, then we will definitely need some simple functions with regex done.
  #4  
Old 22-Jan-2004, 15:12
giobbi giobbi is offline
New Member
 
Join Date: Jan 2004
Posts: 14
giobbi is on a distinguished road
Thanks for the fast reply. Yes, that was the answer i was looking for. Im currently using a filed with a email or weburl so anything there have to be klickable. I tried it and it works for the klick but it seems to refer to my local web-folder and not the actual link like http://www.macosxhints.com becomes http://localhost/web/www.macosxhints.com? Same with emails? Is there another tag for emails?

JDS asked my next question, how to make weburls and email clickable in an large chunk of text automaticly, how do i do that?
  #5  
Old 22-Jan-2004, 18:26
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
By the way, I have been meaning to write some code to do exactly this (parse some string or text and convert URLs into links)...

I'll see if I can come up with something today or tomorrow. Once I am ready, I will post it here.
  #6  
Old 23-Jan-2004, 03:15
basdog22 basdog22 is offline
New Member
 
Join Date: Jan 2004
Posts: 14
basdog22 is on a distinguished road
when you specify a link it must be of this type: http://www.some.com

and not like: http://www.some.com

For emails: <a href="mailto:somemail@some.com">email</a>
  #7  
Old 23-Jan-2004, 03:49
giobbi giobbi is offline
New Member
 
Join Date: Jan 2004
Posts: 14
giobbi is on a distinguished road
Thx JdS, nice of you.

Well, better way (?) is to put http:// i the a href=..tag before the $xxxx to make it a link i think. Don't bother the user with mumbo-jumbo stuff.. : )
  #8  
Old 26-Jan-2004, 04:12
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Sorry giobbi, when I let myself get into fixing the USER/MEMBER groups "promotions and demotions" stuff (for the forum) over the weekend, I completely forgot about this thread and my promise.

I had started work on something... give me a few minutes or so and I will post something up. A little caution though: the code has not been tested extensively and it may not work with some URLs because I don't think I have thought of everything.. yet.

You might have to let me know if you find anything wrong with it, ok?
  #9  
Old 26-Jan-2004, 05:06
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
[function] AutoLink (converts URLS into links inside a string).
  #10  
Old 31-Jan-2004, 02:09
giobbi giobbi is offline
New Member
 
Join Date: Jan 2004
Posts: 14
giobbi is on a distinguished road
Many thanks JdS! Really nice code!
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing PHP code that's stored in a database. JdS MySQL / PHP Forum 3 13-May-2004 09:15
Redirect multiple URLs to one script, masking true URL Maccaday Apache Web Server Forum 1 10-Dec-2003 08:34
WInXp Apache database? Ticoloco Apache Web Server Forum 1 27-Nov-2003 04:21
[Tutorial] MySQL Basics nniehoff MySQL / PHP Forum 15 23-Mar-2003 19:42
Generating simple URLs for search engines jrobbio MySQL / PHP Forum 1 17-Mar-2003 11:22

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:34.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.