This is my code in PHP for searching two tables.
It works but then an error occurs whenever $calls ="SELECT * FROM `table2` WHERE `Company` LIKE '$company'"; gets a variable data with an (') inside. Like Cow's, It's, Isn't or Don't. I've been trying the search in MySQL phpMyAdmin and it shows that with ' you need %'% to get it to show. How do i put %$var% in my $calls variable?
Heres my code:
<?php
$count = 0;
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("Database", $con);
$result = mysql_query("SELECT * FROM table1");
while($row = mysql_fetch_array($result))
{
$count++;
$company = $row['Company'];
$calls ="SELECT * FROM `table2` WHERE `Company` LIKE '$company'";
$result2 = mysql_query($calls);
while($row2 = mysql_fetch_array($result2))
{
$email = $row2['Email Address'];
$cntper = $row2['Contact Person'];
}
echo "<br />--------------------------------------------------------------------------------------<br />Company: ".$company."<br />Email Address: ".$email."<br />Contact Person: ".$cntper."<br />Count: ".$count;
ob_flush();
flush();
}
mysql_close($con);
?>
Please and Thank You...