Page 1 of 1
When pulling info from db, how to link to email or URL
Posted: Fri Apr 09, 2004 4:49 pm
by cdickson
Once I pull information from a database and into a table, how do I then link an email address or URL to the appropriate location?
For example, I have created a table that pulls members of a chamber of commerce into a PHP page. In the database the email addresses and URLs simply show as text, and I don't know how to set up active links.
Posted: Fri Apr 09, 2004 4:54 pm
by Steveo31
Code: Select all
<?php
while($row = mysql_fetch_assoc($query)){
echo "<a href="mailto:$row['email']">$row['email']</a>";
}
?>
Same thing for urls. At least that is how I do it...

Posted: Fri Apr 09, 2004 5:13 pm
by cdickson
Thanks, Steve. Unfortunately I did not mention

- nor include code - the fact that I am using Dreamweaver MX, which generates different code because of the recordsets. If my PHP code currently reads:
Code: Select all
<?php
$maxRows_rsFlorists = 500;
$pageNum_rsFlorists = 0;
if (isset($_GET['pageNum_rsFlorists'])) {
$pageNum_rsFlorists = $_GET['pageNum_rsFlorists'];
}
$startRow_rsFlorists = $pageNum_rsFlorists * $maxRows_rsFlorists;
mysql_select_db($database_hschamber, $hschamber);
$query_rsFlorists = "SELECT * FROM Members WHERE cat_id1 = '79' OR cat_id2 = '79' OR cat_id3 = '79' ORDER BY member_name";
$query_limit_rsFlorists = sprintf("%s LIMIT %d, %d", $query_rsFlorists, $startRow_rsFlorists, $maxRows_rsFlorists);
$rsFlorists = mysql_query($query_limit_rsFlorists, $hschamber) or die(mysql_error());
$row_rsFlorists = mysql_fetch_assoc($rsFlorists);
if (isset($_GET['totalRows_rsFlorists'])) {
$totalRows_rsFlorists = $_GET['totalRows_rsFlorists'];
} else {
$all_rsFlorists = mysql_query($query_rsFlorists);
$totalRows_rsFlorists = mysql_num_rows($all_rsFlorists);
}
$totalPages_rsFlorists = ceil($totalRows_rsFlorists/$maxRows_rsFlorists)-1;
?>
where do I insert the command? And is it the same as you suggested based on the different code I have?
Thanks for helping out!

Posted: Fri Apr 09, 2004 5:26 pm
by patrikG
Have you played with the code? Try inserting it - if it breaks, click undo. If not: congrats.

Posted: Fri Apr 09, 2004 5:59 pm
by Steveo31
patrikG wrote:Have you played with the code? Try inserting it - if it breaks, click undo. If not: congrats.

LMAO! So true!!!
Posted: Sat Apr 10, 2004 8:40 am
by cdickson
LMAO too for me being such a dorky newbie!
Thanks for the help - I appreciate it.
Posted: Sat Apr 10, 2004 10:23 am
by malcolmboston
i used dreamweaver for a few weeks for my first ever PHP app
i cannot emphasise more that you should move away from DW's in built features and code by hand yourself because:
1 - lots of unnecessary code = Bloated Apps
2 - you will never learn this way
3 - Old syntax may become defunct soon, and break your site
4 - more complex to add functionality due to weird coding style
just a few reasons........
Posted: Sat Apr 10, 2004 12:28 pm
by cdickson
Thanks for the advice. I have reached that very same conclusion.
Unfortunately this is my first PHP project and I have a deadline to meet, so I will probably have to get it up and running, and then recode each page as I have time. A lot of it is repetitive, so I will be able to copy and paste much of it.
In the meantime I have purchased several books to help me learn PHP more intimately.
Posted: Sat Apr 10, 2004 12:57 pm
by patrikG
A good free editor, if you're looking for one, is PHPEdit - I think the website is
http://www.phpedit.net/
Posted: Sat Apr 10, 2004 6:54 pm
by cdickson
Thanks for the tip, patrikG. I didn't know these PHP editors existed - and you obviously know what it is like to hand code in Notepad.
I am working on re-coding my pages - your help has been invaluable, and I am truly apprecative.