Selecting 2 columns from multiple tables.
Posted: Sat May 29, 2010 8:05 pm
Hello,
I have 6 tables that have the same structure. (ie. each table has country, abbrev and filename, the columns i want). I'm trying to set up a form that will search through and return all results into a sing UL. Right now I have:
The above code returns no errors but returns no list items as well. I'm new to databases so... What am I doing wrong.
Thanks in advance for any help,
Scott.
I have 6 tables that have the same structure. (ie. each table has country, abbrev and filename, the columns i want). I'm trying to set up a form that will search through and return all results into a sing UL. Right now I have:
Code: Select all
$str = $_REQUEST["str"];
//
$sql = "SELECT 'country', 'filename' FROM europe, asia, africa, northamerica, southamerica, oceania WHERE '*.country' LIKE '%".$str."%' or '*.abbrev' LIKE '%".$str."%'";
//
$res = mysqli_query($link, $sql);
if($res) {
print "Things and stuff.";
print "<ul id=\"countryList\">";
while($newArray = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$name = $newArray["country"];
$file = $newArray["filename"];
print "<li><img src=\"/Flags/".$file."\" width=\"24\" height=\"24\" align=\"absmiddle\" /> ".$name."</li>";
}
print "</ul>";
} else {
printf("error:%s\n", $mysqli_error($link));
}
mysqli_close($link);
Thanks in advance for any help,
Scott.