When pulling info from db, how to link to email or URL
Moderator: General Moderators
When pulling info from db, how to link to email or URL
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.
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.
Code: Select all
<?php
while($row = mysql_fetch_assoc($query)){
echo "<a href="mailto:$row['email']">$row['email']</a>";
}
?>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:
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!
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;
?>Thanks for helping out!
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
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........
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........
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.
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.
A good free editor, if you're looking for one, is PHPEdit - I think the website is http://www.phpedit.net/