Page 1 of 1

(solved)define field type using php?

Posted: Wed Aug 24, 2005 4:32 am
by lostinphp
is it possible to define a filed type in a database( i use mysql and easyphp) as hyperlink using php so dat when displayed the field it can be clicked and used as a link?

Re: define field type using php?

Posted: Wed Aug 24, 2005 4:38 am
by JayBird
lostinphp wrote:is it possible to define a filed type in a database( i use mysql and easyphp) as hyperlink using php so dat when displayed the field it can be clicked and used as a link?
Hmmm...can we have the english version please, i read that 3 times and still not sure what you are wanting to do 8)

Re: define field type using php?

Posted: Wed Aug 24, 2005 4:42 am
by lostinphp
Pimptastic wrote:
lostinphp wrote:is it possible to define a filed type in a database( i use mysql and easyphp) as hyperlink using php so dat when displayed the field it can be clicked and used as a link?
Hmmm...can we have the english version please, i read that 3 times and still not sure what you are wanting to do 8)
ok i have a field called links
i have a text box where i enter a url and this url gets updated in the links field in the database
so when i display the contents of the database id like to be able to click on the url and redirect me to dat page.
so id like to know if there is a way to re define a field type as a hyperlink using php code.

i hope this is english enuf for u..lol i agree my question was pretty incomprehensible.

Posted: Wed Aug 24, 2005 4:47 am
by JayBird
something like this

Code: Select all

<?php 

$query = "SELECT links FROM database_name";

$result = mysql_query($query) or die(mysql_error()); 


if(mysql_num_rows($result) == 0) { 
     echo "There are no links in the database."; 
} else { 

     while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { 

          echo '<a href="'.$row['link'].'" target="_blank">'.$row['link'].'</a><br />'; 

      } 
} 
?>

Posted: Wed Aug 24, 2005 5:17 am
by lostinphp
works fine thank u!