Re: Adding a URL

From: Date: Sun, 30 Mar 2003 08:12:49 +0000
Subject: Re: Adding a URL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-141629@lists.php.net to get a copy of this message
Scott, try changing: print "\t\t<td>$col_value</td>\n"; to: print "\t\t<td><a href=mailto:".$col_value.">$col_value</a></td>\n"; Hope this helps. Hugh ----- Original Message ----- From: "Scott Thompson" <scott_thompson@earthlink.net> To: <php-general@lists.php.net> Sent: Saturday, March 29, 2003 8:53 PM Subject: [PHP] Adding a URL > Hi, > > I am using the following code to query a database and build an HTML table. > > <html> > <head> > <title>SQL Connect</title> > </head> > > <body> > <?php > /* Connecting, selecting database */ > $link = mysql_connect("localhost", "root", "") > or die("Could not connect"); > //print "Connected successfully"; > mysql_select_db("irvington") or die("Could not select database"); > > /* Performing SQL query */ > $query = "SELECT * FROM staff"; > $result = mysql_query($query) or die("Query failed"); > > /* Printing results in HTML */ > print "<table>\n"; > while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { > print "\t<tr>\n"; > foreach ($line as $col_value) { > print "\t\t<td>$col_value</td>\n"; > } > print "\t</tr>\n"; > } > print "</table>\n"; > > /* Free resultset */ > mysql_free_result($result); > > /* Closing connection */ > mysql_close($link); > ?> > > </body> > </html> > > > So far so good... > > The SQL query returns this: > mysql> select * from staff; > +----------------+------------------------------+------------------+ > | name | email | subject | > +----------------+------------------------------+------------------+ > | Scott Thompson | scott_thompson@earthlink.net | Volunteer | > | <sanitized> | <sanitized> | Computer Science | > | Some Teacher | some.teacher@irvington.edu | some subject | > +----------------+------------------------------+------------------+ > 3 rows in set (0.00 sec) > > mysql> > > The above is also essentialy what you see in your browser (sans headers). > > So far so good... > > What I want (and can't figure out) is how to have each email address > have a URL (i.e. mailto:somebody@someaddress.com). > > I'm fairly new to PHP, I hope this question made some sense. > > Suggestions? > > ~Scott > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#141629) next »