I have a page where I am using a PHP while loop to echo the names and addresses of our dealers. For the email link, I want the user to be able to click the link, which would then take him to a form that emails that person.
I know that you can't mix Javascript and PHP, so how do I tell which link the user has clicked on so that I can pass that variable to the form on the next page? Here is my code:
<?php while($row = mysql_fetch_array($result)) {
if ($row['active'] == 1) {
?>
<div id="dealer">
<div id="dealername">
<h3 style="float:left;"><?php echo $row['company']; ?></h3><br/>
<p><?php echo $row['address1']; ?><br/>
<?php if($row['address2'] || $row['address3']) {
echo $row['address2'] . ' ' . $row['address3'] . '<br/>'; } ?>
<?php echo $row['city'];
if ($row['state']) {
echo ', ' . $row['state'];
}
echo ' ' . $row['zip']; ?>
<br />
<?php echo $row['country']; ?>
<br />
<br />
Phone: <strong><?php echo $row['phone1']; ?></strong><?php if ($row['phone2']) {
echo ' or ' . $row['phone2']; } ?><br/>
<?php if($row['fax']) { echo 'Fax: ' . $row['fax']; } ?><br />
</p>
</div>
<?php if ($row['email']) {
echo '<div class="dealerEmail">'. // need help here . '</div>';
} ?>
<br class="clearall" />
</div>
<?php }} ?>
The page that this code appears on is pulling data from a database using a GET statement based on a URL similar to "index.php?state=az".
I've tried making the email link use a "?email=..." format but when I go to the dealer-email.php page there are no parameters in the URL, which I don't get. That's why I'm trying to find some other way to pass some kind of variable to the next page, based on which link the user clicks on.
Hope this is clear. Thanks in advance for your help.