Jump to content

Creating a seach box for my php page.


oriental_express

Recommended Posts

Hi there guys Im currently doing a project and it is to do with storing charity information.

What I would like to do is create a search box that will produce a table of results with whatever matched.

my tabe struction is   

 

type,charitynum,name,address,postcode,county,town,website,phonefax    and is displayed as so from the html. I would be greatful if i had some guidedance on how to create a search box. Any links would be greate as im having a hard time finding suitable threads to follow.  Many thanks :)

 

<table border="1" width="100%">

<tr>

      <td width="35" class="style1"><span class="style5">ID</span></td>
      <td width="78" class="style1"><span class="style5">Type</span></td>
      <td width="78" class="style1"><span class="style5">Charity no. </span></td>
      <td width="132" class="style1"><span class="style5">Name</span></td>
      <td width="194" class="style1"><span class="style5">Address</span></td>
      <td width="78" class="style1"><span class="style5">County</span></td>
      <td width="78" class="style1"><span class="style5">Town</span></td>
      <td width="72" class="style1"><span class="style5">Post code </span></td>
      <td width="150" class="style1"><span class="style5">Website</span></td>
      <td width="91" class="style1"><span class="style5">Phone</span></td>
      <td width="88" class="style1"><span class="style5">Fax</span></td>
</tr>





<p>
  <?PHP



   mysql_pconnect('localhost','root','Adm1n');



   mysql_select_db("charitycw");

   $results = mysql_query("SELECT * FROM charitylist ORDER BY id");

   if ($results){

       while ($a = mysql_fetch_array($results)) {

          echo'<TR>
              <TD>'.$a['id'].'</TD>
      <TD>'.$a['type'].'</TD>
              <TD>'.$a['charitynum'].'</TD>
              <TD>'.$a['name'].'</TD>
              <TD>'.$a['address'].'</TD>
      <TD>'.$a['county'].'</TD>
      <TD>'.$a['town'].'</TD>
              <TD>'.$a['postcode'].'</TD>
              <TD><a href="http://'.preg_replace("~http://~","",$a['website']).'/" target=/"_blank/">'.$a['website'].'</a></TD>
              <TD>'.$a['phone'].'</TD>
              <TD>'.$a['fax'].'</TD>
              </TR>';
       };

       print("</TABLE>");

       } else {

       print("No results to display");

       };



?>
</p>

Link to comment
https://forums.phpfreaks.com/topic/77221-creating-a-seach-box-for-my-php-page/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.