Forum Moderators: coopster

Message Too Old, No Replies

creating hyperlink from data input

         

oriental express

2:20 am on Nov 7, 2007 (gmt 0)

10+ Year Member



Hi there.

Im abit stuck with hyperlinks. Ive used search functions and have found relevent thread but the coding does not match.

I have a php page the displays records from a form.
id name, address, phone, website etc

I would like to make the website data to turn into a hyperlink once submitted.

Here is my following php code that displays the table

=============

$results = mysql_query("SELECT * FROM charitylist");

if ($results){

while ($a = mysql_fetch_array($results)) {

print("<TR>");

print("<TD>$a[id]</TD>");

print("<TD>$a[charitynum]</TD>");

print("<TD>$a[name]</TD>");

print("<TD>$a[address]</TD>");

print("<TD>$a[postcode]</TD>");

print("<TD>$a[website]</TD>"); i would like this to turn whatever is in there to a hyplink

print("<TD>$a[phone]</TD>");

print("<TD>$a[fax]</TD>");


print("</TR>");

};

====================

It would be great if someone got back to me :)

Thank you for your time

Michael

Gian04

4:51 am on Nov 7, 2007 (gmt 0)

10+ Year Member



print("<TD><a href='$a[website]'>$a[website]</a></TD>"

eelixduppy

5:16 am on Nov 7, 2007 (gmt 0)



The above code should actually look like this to be proper:

print('<TD><a href="'.$a['website'].'">.$a['website'].'</a></TD>');

You cannot put the array in the string like it was, however it may still work, it isn't correct. It can be done like I have shown above, or you can surround the array variable in braces {} within the string.