Jump to content


Photo

Query Several Databases From Search Field


  • Please log in to reply
No replies to this topic

#1 Asterixx

Asterixx
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 05 April 2006 - 05:47 PM

<?
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>";
}
?>
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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users