(solved)define field type using php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lostinphp
Forum Commoner
Posts: 44
Joined: Wed Jul 27, 2005 5:10 am
Location: Paris,France.

(solved)define field type using php?

Post 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?
Last edited by lostinphp on Wed Aug 24, 2005 5:16 am, edited 1 time in total.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Re: define field type using php?

Post 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)
lostinphp
Forum Commoner
Posts: 44
Joined: Wed Jul 27, 2005 5:10 am
Location: Paris,France.

Re: define field type using php?

Post 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.
Last edited by lostinphp on Wed Aug 24, 2005 4:48 am, edited 1 time in total.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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 />'; 

      } 
} 
?>
lostinphp
Forum Commoner
Posts: 44
Joined: Wed Jul 27, 2005 5:10 am
Location: Paris,France.

Post by lostinphp »

works fine thank u!
Post Reply