I am in the process of trying to create a search option for my database; however, I need the user to be able to submit one search which looks at three tables in the database. I'm using the following right now and it's working for each individual one (I have to comment out two for it to work). So I have two questions:
(1) What's the best way to get a full search of these columns in the respective tables?
(2) As you can see, I generate a link at the bottom that echo's the results. The problem is that I need the variable to change based on what table it comes from. So, for example, if it comes from the retail table I need the link to be more like
<a href=\"retail?id=$Row[0]\">$Row[1]</a><br>
Full Processing Code
<?PHP
session_start();
//Open Database
include 'dbconnection.php';
//Create Variables
$Term = mysql_real_escape_string($_POST['Term']);
$UserID = $_SESSION['UserID'];
//Verify Password
$SQL = mysql_query("SELECT a.CigarID, b.Description, a.CName from cigar a
LEFT JOIN cd_manufacturer b on a.Manufacturer = b.Code
WHERE a.CName LIKE '%$Term%' or b.Description LIKE '%$Term%'");
/*$SQL = mysql_query("SELECT c.RetailID, c.RName from retail c
WHERE c.RName LIKE '%$Term%'");
$SQL = mysql_query("SELECT d.SpotID, d.SName from spot d
WHERE d.SName LIKE '%$Term%'"); */
while ($Row = mysql_fetch_array($SQL)){
echo "<a href=\"cigar.php?id=$Row[0]\">$Row[1] $Row[2]</a><br>";
}
?>