0

I am working on a Zip Code search, and have successfully built the search. Now, I need to have the ability to click on an image map of a map, and hardcode an href to a dynamic URL

So for example, the search works well displaying contact information for a zip code in PA. But if I have an image map, I'd like the ability for it to display the same contact information if I click the image map of PA on the map image.

Here is the code I'm using to do the search, and at the bottom is the code I need help with for the image map.

              <form action="search6.php" method="post">
                <p><span class="orange16">Zip Code:</span> 
            <input type="text" name="search_name"> <input type="submit" value="Search" />
            </p>
          </form>



            <br />

<table width="700" border="0">              

<?php

if (isset($_POST['search_name'])) {
    $search_name = $_POST['search_name'];
    if (!empty($search_name)) {

        if (strlen($search_name)>=5) {

        $query = "SELECT * FROM `search4` WHERE `ZipCode` LIKE '%".mysql_real_escape_string($search_name)."%'";
        $query_run = mysql_query($query);


        if (mysql_num_rows($query_run)>=1) {
          echo "<table width=700' border='0'>"; 
          echo "<tr>";
          echo "<td width='700' valign='top'><table width='100%' border='0'>";
          echo "<tr>";
          echo "<td><p><strong>Results found:  </strong></p>";
          while ($query_row = mysql_fetch_assoc($query_run)) {{
              echo $query_row['ZipCode'].', ';
              echo $query_row['ZipCity'].', ';
              echo $query_row['ZipState'].'<br><br>';
              echo "</td>";
              echo "</tr>";

              echo "<tr>"; 
              echo "<td>";

              echo '<span class="productdescription"><p>Office:   </p></span></h2>';
              echo $query_row['Office'].'<br>';
              echo $query_row['Address1'].'<br>';
              if(!empty($query_row['Address2'])) // This will skip if the field if it's empty
              echo $query_row['Address2'].'<br>';
              echo $query_row['City'].', ';
              echo $query_row['State'].'  ';
              echo $query_row['Zip'].'<br>';
              echo '<p><strong>Phone Number: </strong></p>';
              echo $query_row['Phone'].'<br>';
              echo '<p><strong>Fax Number: </strong></p>';
              echo $query_row['Fax'].'<br><br>';
              echo "</td>";
              echo "</tr>";
              echo "</table>";
              echo "</td>";

              //BeginImage display result
              $res=mysql_query("select * from Images");

                          {
              echo "<td width='703' align='right' valign='top'>";?> <img src="<?php echo $query_row["Image"]; ?>">  <?php echo "</td>";
              echo "</tr>";
              }


             //EndImage display result

              echo ("<table width='700px' border='0' cellpadding='5' cellspacing='1'>
              <tr>
              <td width='13%' align='left' bgcolor='#C1DDF4'><p><strong>Service Type:</strong></p></td>
              <td width='13%' align='left' bgcolor='#C1DDF4'><p><strong>Name:</strong></p></td>
              <td width='13%' align='left' bgcolor='#C1DDF4'><p><strong>Phone:</strong></p></td>
              <td width='13%' align='left' bgcolor='#C1DDF4'><p><strong>Email:</strong></p></td>
              </tr>");  

              echo ("
              <td align='left'><p><strong>Sales</strong></p></td>
              <td align='left'><p>$query_row[SalesName]</p></td>
              <td align='left'><p>$query_row[SalesPhone]</p></td>
              <td align='left'><p><a href='mailto:$query_row[SalesEmail]'class='admin_links'>$query_row[SalesEmail]</p></a></td>
              </tr>");

              echo ("
              <td align='left'><p><strong>Service</strong></p></td>
              <td align='left'><p>$query_row[ServiceName]</p></td>
              <td align='left'><p>$query_row[ServicePhone]</p></td>
              <td align='left'><p><a href='mailto:$query_row[ServiceEmail]'class='admin_links'>$query_row[ServiceEmail]</p></a></td>
              </tr>");

              echo ("
              <td align='left'><p><strong>Service Coordinator</strong></p></td>
              <td align='left'><p>$query_row[ServiceCoorName]</p></td>
              <td align='left'><p>$query_row[ServiceCoorPhone]</p></td>
              <td align='left'><p><a href='mailto:$query_row[ServiceCoorEmail]'class='admin_links'>$query_row[ServiceCoorEmail]</p></a></td>
              </tr>");            

              echo ("</table>");


              }

              }

        }else{
         echo 'No results found.';
    }

        }else{
         echo 'Your search must be a 5-digit zip code.';
    }



              }

  }


?>              
</table>  

This is the code for the Image map I need help with. I'd like to use the "CustClassID" data row for my value of lets say "23-LA".

<?php
$query = "SELECT * FROM search4 WHERE CustClassID = {$_GET['CustClassID']}";
echo ("<table width='600' border='0'>  
<tr>
<td align='center'> <img src='images/greymap.png' border='0' usemap='#Map' />
  <map name='Map' id='Map'>
    <area shape='rect' coords='42,21,136,98' href='search6.php?CustClassID=23-LA' />
  </map></td>
</tr>
</table>
");
?>   

Basically, is there another way to get the same results as the search, by clicking on specific areas on the imagemap? Please point me in right direction.

GWana
  • 3
  • 2
  • I dont think hardcode means what you think it means – allen213 Sep 26 '13 at 14:30
  • You should use PDO or MySQLi with prepared statements, mysql_ functions have been deprecated. –  Sep 26 '13 at 14:34
  • what do YOU mean with "hardcoded" exactly? – STT LCU Sep 26 '13 at 15:30
  • I want to hardcode the URL in the imagemap, so, lets say I click on Pennsylvania, it will then display the same content results as if I did a zip code search in PA. Does this help to explain it? – GWana Sep 26 '13 at 15:33
  • yes we get that you want to link the image with an url. The question is that you don't know what's the correct meaning of HARDCODED. – STT LCU Sep 27 '13 at 10:10
  • I'd like to add a direct path URL to the data table values to the Imagemap. That is what I mean to hardcoded. It wouldn't necessarliy be dynamic, like the search results are. Do you need an example? – GWana Sep 27 '13 at 13:38

0 Answers0