Jump to content

Query Several Databases From Search Field


Asterixx

Recommended Posts

[code]<?
mysql_connect("localhost","usr","pw");
    
mysql_select_db("my_db");

$search=$_POST["search"];

$result = mysql_query("SELECT * FROM my_table WHERE zip LIKE '%$search%'");

//grab all the content
while($r=mysql_fetch_array($result))
{    
  
   $zip=$r["zip"];
   $contact=$r["contact"];
   $address=$r["address"];
  
   echo "$zip <br> $contact <br> $address <br>";
}
?>[/code]
This is a simple thing to more advanced users. I need to query more than just "my_table" to get the results; the other tables I need to query hold the exact same info as "my_table". I tried delimiting with comas, as in "my_table, my_othertable, my_moretable", but that brought up a SQL error.

Thanks a bunch in advance,
Stephan.
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.