-4

请建议我如何实施这样的事情?我有 10 个表 - 10 个不同类别的字典。所有表都有不同的结构。用户键入一个单词,然后需要显示所有表格的结果,并且您需要指定什么表格的结果是什么。抱歉机器翻译...

$tables = array("test_prefixvoc", 
                "test_prefixvoc_br",
                "test_prefixVoc_fraze",
                "test_prefixVoc_Gloss2",
                "test_prefixvoc_Lingvo",
                "test_prefixvoc_orfo",
                "test_prefixvoc_rb",
                "test_prefixvoc_sinonim",
                "test_prefixVoc_sinonim2",
                "test_prefixvoc_tolk");

$names = array('name', 'NAME', 'Name1', 'Name2', 'Name1', 
'name', 'name', 'Name1', 'Name1', 'NAME');

include 'DB.php';
$con = mysql_connect($host,$user,$pass);
$word =  $_GET["word"];

$array = array();
for($i=0; $i<count($tables); $i++) {
    $dbs = mysql_select_db($tables[$i], $con);
    mysql_query('SET NAMES utf8');  
    $result = mysql_query("SELECT * FROM $tables[$i] WHERE    $names[$i]='$word'");          //query
    $array[$i] = mysql_fetch_row($result);  

    mysql_close();  
}

echo json_encode($array);
4

1 回答 1

1

您需要对每个表进行特定查询,处理所有结果,并将处理后的消息显示给用户。

这就是没有标准化数据库结构的代价。

于 2012-11-20T23:20:38.697 回答