Hi

Does anybody know how using php code to search name and etc from a MySQL table?

I have created a table in mysql "hotspots" and the structure of the tabe is as follows:-

  • postcode
  • city
  • country
  • network
  • address
  • telephone
  • email
  • web
  • map

Is it possible to have a text box to search for hotspots by name or postcode?

Does this make sense

Yours

Russ

    Probably need more informtion. Name is not one of your column names so this is confusing. However, the search would be in a sql statement and probably needs to be addressed on the database list.

    However, the sql statement would probably looks something like this:

    $sql = "SELECT * FROM table WHERE name LIKE '%$_POST['hotspot']%'";
    

    The % on either side of the search criteria allows for something like

    if $_POST['hotspot'] = "bob";
    this select statement will find "bobby joe" and "joe bob"

    Sorry about the choices of names, but I'm from the south 🙂

      Thanks for that!

      I have now made it work but I have one last questions:-

       <td><span class="green">Location<span></td>
           <td><?php echo $map; ?></td>
         </tr>
      

      Is it possible to display a link here ?

      e.g

      <tr>
                    <td><span class="green">Map:</span></td>
                    <td colspan="2"> <a href="#" class="style1" onClick="MM_openBrWindow('http://www.domain.com/file.php','','scrollbars=yes,width=500,height=300')">Click here to view location </a> </td>
                    <td>&nbsp;</td>
                  </tr>
      

        if you pull that url from the database.. sure... uh like this..

        
        $query = "SELECT * FROM table_name";
        
        $data = mysql_query($query);
        
        while($row = mysql_fetch_array($data)) {
              echo "<a href=\"" . $row[url] . "\">" . $row[url] . "</a><br>";
        }
        

          how can I include your code?

          this is what I have in the php file:-

          <tr>
               <td><span class="green">Map:</span></td>
               <td><?php echo $map; ?></td>
             </tr>
          

          *map is displayed as "http://www.domain.com/file1.php"

          ??

            um... lets see, looking at that current snippet of code...

            echo "<a href=\"" . $map . "\">" . $map . "</a><br>";
            

              sorry, I'm being thick 🙂

              how do I include your code?

              <tr> 
                   <td><span class="green">Map:</span></td> 
                   <td><?php echo $map; ?></td> 
              echo "<a href=\"" . $map . "\">" . $map . "</a><br>"; 
                 </tr> 
              

              is this correct?

                When including php variable inside of html, use <?=$variable?>. You can't do any calculations or anything inside there, but you can display the variable.

                I don't know how you're generating your href link, so this is just to give you an idea of how to include php variables inside your html code. Try something like this:

                <?php
                $link = "http://www.domain.com/".$map.".html";
                ?>
                <tr> 
                  <td><span class="green">Map:</span></td>
                  <td><a href="<?=$link?>"><?=$map?></a></td>
                </tr>
                

                Hope this helps 🙂

                  Yes!!!!!!!

                  That worked!!!!

                  Is it possible to display "Open browser Window" ??

                    something like:

                    <a href="<?=$link?>" 
                    MM_openBrWindow('<?=$link?>','','scrollbars=yes,width=500,height=300')">
                    <?=$map?> </a>

                    or just simply

                    <a href="<?=$link?>" target="_blank"><?=$map?></a>
                    

                    if you just want to open a new browser window.

                      Write a Reply...