[thelist] Displaying MySQL Records Using PHP

Richard Harb rharb at earthling.net
Thu Jan 27 17:33:49 CST 2005

I wonder if anyone bothers any more to read any kind of documentation before
posting to any kind of list. I heard there are even books covering the very
basics of just about any subject that take just an hour to read and understand
from start to finish.

My interpretation of your question is that you have URLs in that field of yours.
Like: www.example.com - maybe you even have the http:// part prepended.

So to make that nice collection of characters clickable I suggest to read up on
the HTML spec, namely the A element (
http://www.w3.org/TR/html4/struct/links.html ). And then on the php spec on how
to manipulate strings ( http://www.php.net/manual/en/ref.strings.php ), maybe
even advanced stuff like regex if simple string comparison doesn't suffice.
Don't worry, it's also there in the documentation.

And there are plenty of well answered questions on this subject in the mailing
list archives.

-----Original Message-----
From: Albert Shala
Sent: Thursday, January 27, 2005, 11:02:00 PM
> Here's the code:

> <?php
> $connection = mysql_connect("localhost", "e_novative", "e_novative")
> or die("Error connecting to database");
> mysql_select_db("members", $connection);

> $result = mysql_query("SELECT * FROM members ORDER BY id",
> $connection) or die("error querying database");
> $i = 0;
> while($result_ar = mysql_fetch_assoc($result)){
> <tr <?php if($i%2 == 1){ echo "class='body2'"; }else{echo "class='body1'";}?>>
> <td>
> <?php echo $result_ar['name']; ?></td>
> <td>
> <?php echo $result_ar['email']; ?>
> </td>
> <td>
> <?php echo $result_ar['website']; ?>
> </td>
> </tr>
> <?php
> $i+=1;
> }

> Now the "website" part of my database contains actuall links, and i
> want to have a loop that displays all these links, and of course each
> link is different and the links will be different of course, to
> external and internal sites.

> Thank You.

> Albert

More information about the thelist mailing list