The following code works if there is only one table to search from. However, I need it to search from multiple tables because I have a script that the client uses to upload tables so I need it to be automatic.
(Another script takes care of this
$data = Table1, Table2, etc)
<php>
$sql = "SELECT * FROM $data WHERE lastname LIKE '%$trimmed%'";
$numresults=mysql_query($sql);
$numrows=mysql_num_rows($numresults);
if ($numrows == 0)
{
echo "<b>Results</b>";
echo "<p align=center>Sorry, your search: "" . $trimmed . "" returned zero results.</p>";
exit;
}
if (empty($s)) {
$s=0;
}
$sql .= " limit $s,$limit";
$sql_result = mysql_query($sql,$connection)
or die("Couldn't execute the query.");
<php>
<p align="center"><font face="Trebuchet MS, Arial, Helvetica" size="2">Your
search for "<?echo $var;?>" has returned <?echo @mysql_num_rows($sql_result);?>
result(s).</font></p>
The error I get is:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /.../html/results_name.php on line 145
Results
So...my question is... can this script be modified to select from multiple tables, or does it have to be altered and how?
Please keep in mind that I have not been doing this for very long ;-)