Jump to content

converting query result into a hyperlink


mikalchristian

Recommended Posts

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>';  }  } 

?>

   

Link to comment
Share on other sites

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 />';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.