[英]Request in 10 tables. Tables have different structures
請建議我如何實現這樣的事情? 我有 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);
您需要對每個表進行特定查詢,處理所有結果,並將處理后的消息顯示給用戶。
這就是沒有標准化數據庫結構的代價。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.