mikalchristian Posted January 21, 2011 Share Posted January 21, 2011 Hello, I am new to the board and PHP. I created a simple store locator app with PHP. It pulls the info from a database. I want to take the website field from the table, once it is returned from the query, and have it print out a a hyperlink. Please help. Thanks, I have posted most of the relevant code. <?php if (isset ($stores)) { if (!empty ($stores)) { echo '<p><strong>' . count ($stores) . ' results were found.</strong></p>'; foreach ($stores as $value) { echo '<p><strong>' . $value['name'] . '</strong><br />'; echo $value['address'] . '<br />'; echo $value['town'] . ', ' . $value['state'] . ' ' . $value['postal']; echo ' <a target="_blank" href="http://maps.google.com/maps?q=', $value['address'], ' ', $value['town'], ', ', $value['state'], ' ', $value['postal'],'">Map this location</a><br />'; echo 'Phone: ' . $value['phone'] . '<br />'; echo 'Website: ' . $value['website'] . '<br />'; echo 'Email: ' . $value['email'] . '<br />'; echo 'Hours: ' . $value['hours'] ; echo '</p>'; } } else { echo '<p><strong>No results found</strong></p>'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/225246-converting-query-result-into-a-hyperlink/ Share on other sites More sharing options...
jcbones Posted January 21, 2011 Share Posted January 21, 2011 So what about this doesn't work. You have the hyperlink in there. Quote Link to comment https://forums.phpfreaks.com/topic/225246-converting-query-result-into-a-hyperlink/#findComment-1163286 Share on other sites More sharing options...
beegro Posted January 21, 2011 Share Posted January 21, 2011 Assuming it's a fully qualified URL echo 'Website: <a href="'.$value['website'].'">' . $value['website'] . '</a><br />'; Quote Link to comment https://forums.phpfreaks.com/topic/225246-converting-query-result-into-a-hyperlink/#findComment-1163287 Share on other sites More sharing options...
Pikachu2000 Posted January 21, 2011 Share Posted January 21, 2011 If this doesn't work, your $value array is probably empty, which would require figuring out why it's empty. echo ' <a target="_blank" href="http://'; echo urlencode("maps.google.com/maps?q={$value['address']} {$value['town']} {$value['state']} {$value['postal']}"); echo '">Map this location</a><br />'; Quote Link to comment https://forums.phpfreaks.com/topic/225246-converting-query-result-into-a-hyperlink/#findComment-1163312 Share on other sites More sharing options...
mikalchristian Posted January 21, 2011 Author Share Posted January 21, 2011 Hey Guys, thanks for all your help! I got theanswer I needed. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/225246-converting-query-result-into-a-hyperlink/#findComment-1163356 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.